From e45f98d266fb5f318720d6bb107434b4ad314cbe Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 10 May 2017 17:05:43 +0900 Subject: [PATCH 01/16] Common : change ecore to ecore-core to remove dependacy ecore is too heavy, so change it to ecore-core to remove dependancy. Change-Id: Id93b8bd0a36ab50d7e9d1804ac65045e4d32aced Signed-off-by: lokilee73 --- CMakeLists.txt | 2 +- packaging/deviced.spec | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 700a190..0d32ba4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,7 +162,7 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src/deviced) SET(PKG_MODULES - ecore + ecore-core edbus vconf dlog diff --git a/packaging/deviced.spec b/packaging/deviced.spec index edbba61..a5c83b7 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -17,7 +17,8 @@ Source2: libdeviced.manifest BuildRequires: cmake BuildRequires: libattr-devel BuildRequires: gettext-devel -BuildRequires: pkgconfig(ecore) +BuildRequires: pkgconfig(mount) +BuildRequires: pkgconfig(ecore-core) BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(device-node) -- 2.7.4 From 3a185bd151c21b420c1d852163596e38f0a44074 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Wed, 10 May 2017 16:39:03 +0900 Subject: [PATCH 02/16] display: add privilege for lockstate dbus method [Problem] Any app can block holdkey using lockstate dbus method directly. This makes security issues. [Solution] Add new dbus method lockstate_nopt which doesn't support hold key block. And only internal services are allowed to call lockstate dbus method. Change-Id: Ic075c51e46c9250f1d5db847257f4f270c973ca9 Signed-off-by: Yunmi Ha --- scripts/deviced.conf | 4 ++ src/display/display-dbus.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/scripts/deviced.conf b/scripts/deviced.conf index b7c7ff7..444c6bf 100644 --- a/scripts/deviced.conf +++ b/scripts/deviced.conf @@ -24,6 +24,10 @@ send_interface="org.tizen.system.deviced.display" privilege="http://tizen.org/privilege/display"/> + Date: Tue, 23 May 2017 15:22:20 +0900 Subject: [PATCH 03/16] block: Remove useless code Change-Id: I7de61a2f5fbd354747c64556da73ef4e7f92fb1d Signed-off-by: pr.jung --- src/core/edbus-handler.c | 175 ----------------------------------------------- src/core/edbus-handler.h | 7 -- 2 files changed, 182 deletions(-) diff --git a/src/core/edbus-handler.c b/src/core/edbus-handler.c index 629c797..a609be5 100644 --- a/src/core/edbus-handler.c +++ b/src/core/edbus-handler.c @@ -78,9 +78,7 @@ static dd_list *edbus_handler_list; static dd_list *edbus_watch_list; static int edbus_init_val; static DBusConnection *conn; -static DBusConnection *conn_block; static E_DBus_Connection *edbus_conn; -static E_DBus_Connection *edbus_conn_block; static DBusPendingCall *edbus_request_name; static DBusHandlerResult message_filter(DBusConnection *connection, @@ -91,11 +89,6 @@ DBusConnection *get_dbus_connection(void) return conn; } -DBusConnection *get_block_dbus_connection(void) -{ - return conn_block; -} - E_DBus_Object *register_edbus_object(const char *object_path, void *data) { E_DBus_Object *object; @@ -114,24 +107,6 @@ E_DBus_Object *register_edbus_object(const char *object_path, void *data) return object; } -E_DBus_Object *register_block_edbus_object(const char *object_path, void *data) -{ - E_DBus_Object *object; - - if (!object_path) { - _E("invalid parameter"); - return NULL; - } - - object = e_dbus_object_add(edbus_conn_block, object_path, data); - if (!object) { - _E("fail to add object for %s", object_path); - return NULL; - } - - return object; -} - void unregister_edbus_object(E_DBus_Object *object) { if (!object) @@ -164,30 +139,6 @@ static int register_edbus_interface(struct edbus_object *object) return 0; } -static int register_block_edbus_interface(struct edbus_object *object) -{ - if (!object) { - _E("object is invalid value!"); - return -1; - } - - object->obj = e_dbus_object_add(edbus_conn_block, object->path, NULL); - if (!object->obj) { - _E("fail to add edbus obj"); - return -1; - } - - object->iface = e_dbus_interface_new(object->interface); - if (!object->iface) { - _E("fail to add edbus interface"); - return -1; - } - - e_dbus_object_interface_attach(object->obj, object->iface); - - return 0; -} - E_DBus_Interface *get_edbus_interface(const char *path) { int i; @@ -377,38 +328,6 @@ int broadcast_edbus_signal(const char *path, const char *interface, return 0; } -int broadcast_block_edbus_signal(const char *path, const char *interface, - const char *name, const char *sig, char *param[]) -{ - DBusMessage *msg; - DBusMessageIter iter; - int r; - - msg = dbus_message_new_signal(path, interface, name); - if (!msg) { - _E("fail to allocate new %s.%s signal", interface, name); - return -EPERM; - } - - dbus_message_iter_init_append(msg, &iter); - r = append_variant(&iter, sig, param); - if (r < 0) { - _E("append_variant error(%d)", r); - return -EPERM; - } - - r = dbus_connection_send(conn_block, msg, NULL); - dbus_message_unref(msg); - - if (r != TRUE) { - _E("dbus_connection_send error(%s:%s-%s)", - path, interface, name); - return -ECOMM; - } - - return 0; -} - static void print_watch_item(void) { struct watch_info *watch; @@ -784,60 +703,6 @@ int register_edbus_interface_and_method(const char *path, return 0; } -int register_block_edbus_interface_and_method(const char *path, - const char *interface, - const struct edbus_method *edbus_methods, int size) -{ - struct edbus_object *obj; - dd_list *elem; - int ret; - - if (!path || !interface || !edbus_methods || size < 1) { - _E("invalid parameter"); - return -EINVAL; - } - - /* find matched obj */ - DD_LIST_FOREACH(edbus_object_list, elem, obj) { - if (strncmp(obj->path, path, strlen(obj->path)) == 0 && - strncmp(obj->interface, interface, strlen(obj->interface)) == 0) { - _I("found matched item : obj(%p)", obj); - break; - } - } - - /* if there is no matched obj */ - if (!obj) { - obj = malloc(sizeof(struct edbus_object)); - if (!obj) { - _E("fail to allocate %s interface", path); - return -ENOMEM; - } - - obj->path = strdup(path); - obj->interface = strdup(interface); - - ret = register_block_edbus_interface(obj); - if (ret < 0) { - _E("fail to register %s interface(%d)", obj->path, ret); - free(obj->path); - free(obj->interface); - free(obj); - return ret; - } - - DD_LIST_APPEND(edbus_object_list, obj); - } - - ret = register_method(obj->iface, edbus_methods, size); - if (ret < 0) { - _E("fail to register %s method(%d)", obj->path, ret); - return ret; - } - - return 0; -} - int unregister_edbus_interface_all(void) { struct edbus_object *obj; @@ -1014,18 +879,6 @@ void edbus_init(void *data) retry = 0; do { - conn_block = dbus_bus_get_private(DBUS_BUS_SYSTEM, &error); - if (conn_block) - break; - if (retry == EDBUS_INIT_RETRY_COUNT) { - _E("fail to get dbus"); - goto out1; - } - retry++; - } while (retry <= EDBUS_INIT_RETRY_COUNT); - - retry = 0; - do { edbus_conn = e_dbus_connection_setup(conn); if (edbus_conn) break; @@ -1038,18 +891,6 @@ void edbus_init(void *data) retry = 0; do { - edbus_conn_block = e_dbus_connection_setup(conn_block); - if (edbus_conn) - break; - if (retry == EDBUS_INIT_RETRY_COUNT) { - _E("fail to get edbus"); - goto out2; - } - retry++; - } while (retry <= EDBUS_INIT_RETRY_COUNT); - - retry = 0; - do { edbus_request_name = e_dbus_request_name(edbus_conn, DEVICED_BUS_NAME, DBUS_NAME_FLAG_REPLACE_EXISTING, request_name_cb, NULL); if (edbus_request_name) @@ -1061,19 +902,6 @@ void edbus_init(void *data) retry++; } while (retry <= EDBUS_INIT_RETRY_COUNT); - retry = 0; - do { - edbus_request_name = e_dbus_request_name(edbus_conn_block, STORAGE_BUS_NAME, - DBUS_NAME_FLAG_REPLACE_EXISTING, request_name_cb, NULL); - if (edbus_request_name) - break; - if (retry == EDBUS_INIT_RETRY_COUNT) { - _E("fail to request edbus name"); - goto out3; - } - retry++; - } while (retry <= EDBUS_INIT_RETRY_COUNT); - for (i = 0; i < ARRAY_SIZE(edbus_objects); i++) { ret = register_edbus_interface(&edbus_objects[i]); if (ret < 0) { @@ -1089,10 +917,8 @@ void edbus_init(void *data) out3: e_dbus_connection_close(edbus_conn); - e_dbus_connection_close(edbus_conn_block); out2: dbus_connection_set_exit_on_disconnect(conn, FALSE); - dbus_connection_set_exit_on_disconnect(conn_block, FALSE); out1: e_dbus_shutdown(); } @@ -1103,6 +929,5 @@ void edbus_exit(void *data) unregister_edbus_watch_all(); unregister_edbus_interface_all(); e_dbus_connection_close(edbus_conn); - e_dbus_connection_close(edbus_conn_block); e_dbus_shutdown(); } diff --git a/src/core/edbus-handler.h b/src/core/edbus-handler.h index 8dc04b9..487b5d0 100644 --- a/src/core/edbus-handler.h +++ b/src/core/edbus-handler.h @@ -42,16 +42,11 @@ static inline DBusMessage *make_reply_message(DBusMessage *msg, int ret) } DBusConnection *get_dbus_connection(void); -DBusConnection *get_block_dbus_connection(void); E_DBus_Object *register_edbus_object(const char *object_path, void *data); -E_DBus_Object *register_block_edbus_object(const char *object_path, void *data); void unregister_edbus_object(E_DBus_Object *object); int register_edbus_interface_and_method(const char *path, const char *interface, const struct edbus_method *edbus_methods, int size); -int register_block_edbus_interface_and_method(const char *path, - const char *interface, - const struct edbus_method *edbus_methods, int size); int register_edbus_method(const char *path, const struct edbus_method *edbus_methods, int size); int register_edbus_signal_handler(const char *path, const char *interface, const char *name, E_DBus_Signal_Cb cb); @@ -61,8 +56,6 @@ E_DBus_Interface *get_edbus_interface(const char *path); pid_t get_edbus_sender_pid(DBusMessage *msg); int broadcast_edbus_signal(const char *path, const char *interface, const char *name, const char *sig, char *param[]); -int broadcast_block_edbus_signal(const char *path, const char *interface, - const char *name, const char *sig, char *param[]); int register_edbus_watch(const char *sender, void (*func)(const char *sender, void *data), void *data); int unregister_edbus_watch(const char *sender, -- 2.7.4 From 6f0a605ded6b9d4f0ea5c43fb7fabaa104da8fcc Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Tue, 30 May 2017 13:40:03 +0900 Subject: [PATCH 04/16] usb: fix stack-buffer-underflow issue Change-Id: I77b72b01a5182680f10d7a0a4a49e0e400ff63f5 Signed-off-by: Yunmi Ha --- src/usb/usb-state.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/usb/usb-state.c b/src/usb/usb-state.c index 300df18..043340c 100755 --- a/src/usb/usb-state.c +++ b/src/usb/usb-state.c @@ -115,6 +115,7 @@ char *usb_state_get_mode_str(unsigned int mode, char *str, size_t len) { int i; int ret; + int flag = 0; if (mode == USB_FUNCTION_NONE) { snprintf(str, len, "%s", ""); @@ -127,12 +128,15 @@ char *usb_state_get_mode_str(unsigned int mode, char *str, size_t len) return str; str += ret; len -= ret; + flag = 1; } } + if (flag == 1) { + /* eliminate trailing comma */ + *(str - 1) = '\0'; + } } - /* eliminate trailing comma */ - *(str - 1) = '\0'; return str; } -- 2.7.4 From 785f38282cd77eb2eb105dd2ac487928a30c354c Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Wed, 7 Jun 2017 16:38:34 +0900 Subject: [PATCH 05/16] auto-test: support battery dbus test deviced-auto-test package was added. Now it supports battery dbus method test only. (other module will be updated.) This is optional package. If you want to use this, install device-auto-test package manually and run below command. Then you can see detail usage for this tool. $/usr/bin/deviced-auto-test usage: deviced-auto-test [PROFILE] [MODULE] [UNIT-METHOD] [OPTS] Change-Id: Id8824459e88286d8f0074b05b2e1f93690a6e4d2 Signed-off-by: Yunmi Ha --- CMakeLists.txt | 1 + packaging/deviced.spec | 14 ++ src/auto-test/CMakeLists.txt | 62 ++++++ src/auto-test/auto-test.conf | 14 ++ src/auto-test/battery.c | 498 +++++++++++++++++++++++++++++++++++++++++++ src/auto-test/config.c | 93 ++++++++ src/auto-test/config.h | 30 +++ src/auto-test/main.c | 75 +++++++ src/auto-test/result.c | 45 ++++ src/auto-test/test.c | 83 ++++++++ src/auto-test/test.h | 109 ++++++++++ 11 files changed, 1024 insertions(+) create mode 100644 src/auto-test/CMakeLists.txt create mode 100644 src/auto-test/auto-test.conf create mode 100644 src/auto-test/battery.c create mode 100644 src/auto-test/config.c create mode 100644 src/auto-test/config.h create mode 100644 src/auto-test/main.c create mode 100644 src/auto-test/result.c create mode 100644 src/auto-test/test.c create mode 100644 src/auto-test/test.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d32ba4..86e554e 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -293,3 +293,4 @@ ADD_SUBDIRECTORY(src/devicectl) IF(TIZEN_FEATURE_USBHOST_TEST STREQUAL on) ADD_SUBDIRECTORY(src/usb-host-ffs-test-daemon) ENDIF() +ADD_SUBDIRECTORY(src/auto-test) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index a5c83b7..c994406 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -134,6 +134,14 @@ Deviced library for device control (devel). Because this is internal interface, every profile MUST have the same devel package. +%package auto-test +Summary: Deviced auto test tool +Group: System/Utilities + +%description auto-test +Deviced helper programs. +This package can be installed optional for auto dbus test. + %prep %setup -q @@ -532,3 +540,9 @@ mv %{_bindir}/deviced %{_bindir}/deviced.ivi %{_includedir}/deviced/*.h %{_libdir}/libdeviced.so %{_libdir}/pkgconfig/deviced.pc + +%files auto-test +%manifest deviced.manifest +%license LICENSE +%{_bindir}/deviced-auto-test +%config %{_sysconfdir}/deviced/auto-test.conf diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt new file mode 100644 index 0000000..6ca20db --- /dev/null +++ b/src/auto-test/CMakeLists.txt @@ -0,0 +1,62 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(deviced-auto-test C) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src) + +IF("${PROFILE}" STREQUAL "wearable") + SET(PROFILE wearable) +ELSEIF("${PROFILE}" STREQUAL "tv") + SET(PROFILE tv) +ELSE() + SET(PROFILE mobile) +ENDIF() + +IF("$ENV{CFLAGS}" MATCHES "-DTIZEN_ENGINEER_MODE") + OPTION(USE_ENGINEER_MODE "Use Engineer mode" ON) +ENDIF() + +SET(SRCS + test.c + main.c + result.c + ../core/config-parser.c + config.c + + battery.c +) + +# extcon test +#SET(SRCS ${SRCS} +# storage.c +# usb.c +# hdmi.c +# earjack.c +#) + +#IF(NOT PROFILE STREQUAL wearable) +#SET(SRCS ${SRCS} +# cradle.c +# keyboard.c +# tvout.c +#) +#ENDIF(NOT PROFILE STREQUAL wearable) + +INCLUDE(FindPkgConfig) +pkg_check_modules(pkgs REQUIRED edbus) + +FOREACH(flag ${pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -g -fno-omit-frame-pointer") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIE") +SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed -pie") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DENABLE_TEST_DLOG") + +ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} shared) + +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/auto-test.conf DESTINATION /etc/deviced) diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf new file mode 100644 index 0000000..f4fe9c7 --- /dev/null +++ b/src/auto-test/auto-test.conf @@ -0,0 +1,14 @@ +[mobile] +battery=1 + +[wearable] +battery=1 + +[tv] +battery=0 + +[ivi] +battery=0 + +[common] +battery=0 diff --git a/src/auto-test/battery.c b/src/auto-test/battery.c new file mode 100644 index 0000000..8271b49 --- /dev/null +++ b/src/auto-test/battery.c @@ -0,0 +1,498 @@ +/* + * test + * + * Copyright (c) 2016 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. + */ +#include +#include "test.h" + +#define METHOD_BATTERY_TIMETOFULL "TimeToFull" +#define METHOD_BATTERY_TIMETOEMPTY "TimeToEmpty" +#define METHOD_BATTERY_SETLOWBATLEVEL "SetLowbatLevel" +#define METHOD_BATTERY_GETLOWBATLEVEL "GetLowbatLevel" +#define METHOD_BATTERY_CHARGERSTATUS "ChargerStatus" +#define METHOD_BATTERY_CHARGENOW "ChargeNow" +#define METHOD_BATTERY_STATUSLOW "BatteryStatusLow" +#define METHOD_BATTERY_GETPERCENT "GetPercent" +#define METHOD_BATTERY_GETPERCENTRAW "GetPercentRaw" +#define METHOD_BATTERY_ISFULL "IsFull" +#define METHOD_BATTERY_HEALTH "GetHealth" +#define METHOD_BATTERY_GETINFO "GetBatteryInfo" +#define METHOD_BATTERY_POWERSUPPLY "power_supply" + +#define CHARGEFULL_NAME "Full" +#define CHARGENOW_NAME "Charging" +#define DISCHARGE_NAME "Discharging" +#define NOTCHARGE_NAME "Not charging" + +#define GOOD_NAME "Good" +#define OVERHEAT_NAME "Overheat" +#define TEMPCOLD_NAME "Cold" +#define OVERVOLT_NAME "Over voltage" + +#define POWER_SUPPLY_TYPE_BATTERY "1" +#define POWER_SUPPLY_TYPE_UPS "2" + +#define PRESENT_ABNORMAL "0" +#define PRESENT_NORMAL "1" + +#define DEFAULT_LOWBATLEVEL 15 + +#define S_ENTER 1 +#define S_LEAVE 0 + +static struct power_supply_type { + char *scenario; + int status; + char *capacity; + char *charge_status; + char *health; + char *online; + char *present; + char *name; +} power_supply_types[] = { + {"norm", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, + {"norm", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, + {"norm", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"heat1", S_ENTER, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, + {"heat1", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(H) BEFORE CHARGE"}, + {"heat1", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, + {"heat1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"heat2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, + {"heat2", S_ENTER, "100", NOTCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(H) AFTER CHARGE"}, + {"heat2", S_LEAVE, "100", DISCHARGE_NAME, OVERHEAT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, + {"heat2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"cold1", S_ENTER, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, + {"cold1", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(L) BEFORE CHARGE"}, + {"cold1", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, + {"cold1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"cold2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, + {"cold2", S_ENTER, "100", NOTCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "HEALTH(L) AFTER CHARGE"}, + {"cold2", S_LEAVE, "100", DISCHARGE_NAME, TEMPCOLD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"}, + {"cold2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"ovp", S_ENTER, "100", DISCHARGE_NAME, OVERVOLT_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "OVP"}, + {"ovp", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"pres1", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, NULL}, + {"pres1", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, "PRESENT BEFORE CHARGE"}, + {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, "DISCHARGE"}, + {"pres1", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"pres2", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, NULL}, + {"pres2", S_ENTER, "100", NOTCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_ABNORMAL, "PRESENT AFTER CHARGE"}, + {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_ABNORMAL, "DISCHARGE"}, + {"pres2", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, NULL}, /* init */ + + {"bat15", S_ENTER, "15", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 15%"}, /* lowbat 15% */ + {"bat15", S_LEAVE, "15", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 15%"}, + {"bat5", S_ENTER, "5", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 5%"}, /* lowbat 5% */ + {"bat5", S_LEAVE, "5", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 5%"}, + {"bat3", S_ENTER, "3", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 3%"}, /* lowbat 3% */ + {"bat3", S_LEAVE, "3", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 3%"}, + {"bat1", S_ENTER, "1", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "LOWBAT 1%"}, /* lowbat 1% */ + {"bat1", S_LEAVE, "1", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "LOWBAT 1%"}, + + {"ta", S_ENTER, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, /* charging */ + {"ta", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"},/* discharging */ + + {"full", S_ENTER, "100", CHARGEFULL_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CHARGE"}, /* full */ + {"full", S_LEAVE, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "DISCHARGE"},/* discharging */ + + {"capa", S_ENTER, "100", DISCHARGE_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_BATTERY, PRESENT_NORMAL, "CAPACITY"},/* discharging */ + {"capa", S_LEAVE, "100", CHARGENOW_NAME, GOOD_NAME, POWER_SUPPLY_TYPE_UPS, PRESENT_NORMAL, "CAPACITY"},/* charging */ +}; + + +static bool get_battery_method(const char *method, int *value) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + method, NULL, NULL); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + _I("success (%s): %d", method, val); + ret = TRUE; + if (NULL != value) + *value = val; + } + + dbus_message_unref(msg); + return ret; +} + +static bool get_battery_method_vconf(const char *method) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + method, NULL, NULL); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if (val == -EIO) { + _E("fail (%s): return fail", method); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool get_battery_time_to_full(void) +{ + return get_battery_method(METHOD_BATTERY_TIMETOFULL, NULL); +} + +static bool get_battery_time_to_empty(void) +{ + return get_battery_method(METHOD_BATTERY_TIMETOEMPTY, NULL); +} + +static bool get_battery_low_level(int *value) +{ + return get_battery_method(METHOD_BATTERY_GETLOWBATLEVEL, value); +} + +static bool set_battery_low_level(int newlevel) +{ + DBusMessage *msg; + int getlevel = -1; + int val = -1; + char *param[1]; + char str_mode[10]; + bool ret = FALSE; + + snprintf(str_mode, sizeof(str_mode), "%d", newlevel); + param[0] = str_mode; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + METHOD_BATTERY_SETLOWBATLEVEL, "i", param); + + if (!msg) { + _E("fail : no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) { + _E("fail : no message"); + goto out; + } else { + if (newlevel <= DEFAULT_LOWBATLEVEL) { + if (0 != val) { + _I("success : can't set low level (%d) smaller than default (%d)", newlevel, DEFAULT_LOWBATLEVEL); + ret = TRUE; + } else { + _E("fail : can't set low level (%d) smaller than default (%d), but returned success", newlevel, DEFAULT_LOWBATLEVEL); + } + goto out; + } else { + if (0 != val) { + _E("fail : return fail"); + goto out; + } + } + } + + if (!get_battery_low_level(&getlevel)) { + _E("fail : can't get battery low level"); + } else { + if (getlevel == newlevel) { + _I("success : %d", newlevel); + ret = TRUE; + } else { + _E("fail : set low level %d, but current low level %d", newlevel, getlevel); + } + } +out: + dbus_message_unref(msg); + return ret; +} + +static bool get_battery_charger_status() +{ + return get_battery_method_vconf(METHOD_BATTERY_CHARGERSTATUS); +} + +static bool get_battery_charge_now() +{ + return get_battery_method(METHOD_BATTERY_CHARGENOW, NULL); +} + +static bool get_battery_status_low() +{ + return get_battery_method_vconf(METHOD_BATTERY_STATUSLOW); +} + +static bool get_battery_percent() +{ + return get_battery_method(METHOD_BATTERY_GETPERCENT, NULL); +} + +static bool get_battery_percent_raw() +{ + return get_battery_method(METHOD_BATTERY_GETPERCENTRAW, NULL); +} + +static bool get_battery_is_full() +{ + return get_battery_method(METHOD_BATTERY_ISFULL, NULL); +} + +static bool get_battery_health() +{ + return get_battery_method(METHOD_BATTERY_HEALTH, NULL); +} + +static bool get_battery_info() +{ + DBusMessage *msg; + int val[6]; + bool ret = FALSE; + char *argv[3]; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + METHOD_BATTERY_GETINFO, NULL, NULL); + if (!msg) { + _E("fail: no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, + DBUS_TYPE_INT32, &val[0], //return value + DBUS_TYPE_STRING, &argv[0], //status + DBUS_TYPE_STRING, &argv[1], //health + DBUS_TYPE_STRING, &argv[2], //power source + DBUS_TYPE_INT32, &val[1], //online + DBUS_TYPE_INT32, &val[2], //present + DBUS_TYPE_INT32, &val[3], //capacity + DBUS_TYPE_INT32, &val[4], //current_now + DBUS_TYPE_INT32, &val[5], //current_average + DBUS_TYPE_INVALID) == 0) + _E("fail: no message"); + else { + if (val[0] < 0) { + _E("fail: return fail"); + } else { + _I("success: %s %s %s %d %d %d %d %d", argv[0], argv[1], argv[2], val[1], val[2], val[3], val[4], val[5]); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_battery_power_supply(int index) +{ + DBusError err; + DBusMessage *msg; + int val; + bool ret = FALSE; + char *param[7]; + + param[0] = POWER_SUBSYSTEM; + param[1] = "5"; + param[2] = power_supply_types[index].capacity; + param[3] = power_supply_types[index].charge_status; + param[4] = power_supply_types[index].health; + param[5] = power_supply_types[index].online; + param[6] = power_supply_types[index].present; + + _I("C(%s , %s) P(%s) STATUS(%s) HEALTH(%s)", + power_supply_types[index].capacity, + power_supply_types[index].online, + power_supply_types[index].present, + power_supply_types[index].charge_status, + power_supply_types[index].health); + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_BATTERY, + DEVICED_INTERFACE_BATTERY, + POWER_SUBSYSTEM, "sisssss", param); + if (!msg) { + _E("fail: no reply"); + return ret; + } + + dbus_error_init(&err); + + if (dbus_message_get_args(msg, &err, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) { + _E("fail: no message : [%s:%s]", err.name, err.message); + val = -EBADMSG; + } else { + if (val < 0) { + _E("fail: return fail"); + } else { + _I("success: %d", val); + ret = TRUE; + } + } + + /* + if (power_supply_types[index].name != NULL) + _I("++++++++++[START] %s ++++++++++", power_supply_types[index].name); + _I("C(%s , %s) P(%s) STATUS(%s) HEALTH(%s)", + power_supply_types[index].capacity, + power_supply_types[index].online, + power_supply_types[index].present, + power_supply_types[index].charge_status, + power_supply_types[index].health); + if (power_supply_types[index].name != NULL) + _I("++++++++++[END] %s ++++++++++", power_supply_types[index].name); + if (val < 0) + _R("[NG] ---- %s", __func__); + else + _R("[OK] ---- %s : C(%s , %s) P(%s) S(%s) H(%s)", + __func__, + power_supply_types[index].capacity, + power_supply_types[index].online, + power_supply_types[index].present, + power_supply_types[index].charge_status, + power_supply_types[index].health); + */ + dbus_message_unref(msg); + dbus_error_free(&err); + sleep(TEST_WAIT_TIME_INTERVAL); + + return ret; +} + +void battery_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (get_battery_time_to_full()) ? s++ : f++; + (get_battery_time_to_empty()) ? s++ : f++; + (get_battery_low_level(NULL)) ? s++ : f++; + (set_battery_low_level(10)) ? s++ : f++; + (set_battery_low_level(50)) ? s++ : f++; + (get_battery_charger_status()) ? s++ : f++; + (get_battery_charge_now()) ? s++ : f++; + (get_battery_status_low()) ? s++ : f++; + (get_battery_percent()) ? s++ : f++; + (get_battery_percent_raw()) ? s++ : f++; + (get_battery_is_full()) ? s++ : f++; + (get_battery_health()) ? s++ : f++; + (get_battery_info()) ? s++ : f++; + + for (int index = 0; index < ARRAY_SIZE(power_supply_types); index++) + (set_battery_power_supply(index)) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void battery_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + battery_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void battery_exit(void *data) +{ + _I("end test"); + +} + +static int battery_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + _I("start test"); + battery_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_TIMETOFULL)) { + get_battery_time_to_full(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_TIMETOEMPTY)) { + get_battery_time_to_empty(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_GETLOWBATLEVEL)) { + get_battery_low_level(NULL); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_SETLOWBATLEVEL)) { + set_battery_low_level(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_CHARGERSTATUS)) { + get_battery_charger_status(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_CHARGENOW)) { + get_battery_charge_now(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_STATUSLOW)) { + get_battery_status_low(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_GETPERCENT)) { + get_battery_percent(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_GETPERCENTRAW)) { + get_battery_percent_raw(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_ISFULL)) { + get_battery_is_full(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_HEALTH)) { + get_battery_health(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_GETINFO)) { + get_battery_info(); + } else if (0 == strcasecmp(argv[3], METHOD_BATTERY_POWERSUPPLY)) { + for (int index = 0; index < ARRAY_SIZE(power_supply_types); index++) + set_battery_power_supply(index); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops battery_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "battery", + .init = battery_init, + .exit = battery_exit, + .unit = battery_unit, +}; + +TEST_OPS_REGISTER(&battery_test_ops) diff --git a/src/auto-test/config.c b/src/auto-test/config.c new file mode 100644 index 0000000..fb2acd8 --- /dev/null +++ b/src/auto-test/config.c @@ -0,0 +1,93 @@ +/* + * deviced + * + * Copyright (c) 2014 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. + */ +#include +#include + +#include "core/config-parser.h" + +#include "test.h" +#include "config.h" + +#define CONF_FILE "/etc/deviced/auto-test.conf" +#define DEF_PROFILE "mobile" + +static char section[256] = {'\0',}; +static GHashTable *config_hash = NULL; + +static int load_config(struct parse_result *result, void *user_data) +{ + int value = 0; + + if (!MATCH(result->section, section)) + return 0; + + _D("%s,%s,%s", result->section, result->name, result->value); + + value = atoi(result->value); + if ((value == 1) && !g_hash_table_contains(config_hash, result->name)) + g_hash_table_add(config_hash, g_strdup(result->name)); + + return 0; +} + +void test_config_load(const char *profile) +{ + int len = 0; + int ret = 0; + + if (NULL != profile) len = strlen(profile); + if ((0 >= len) || (255 < len)) + strncpy(section, DEF_PROFILE, 255); + else + strncpy(section, profile, 255); + + + if (NULL != config_hash) + test_config_unload(); + + config_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + if (NULL == config_hash) { + _E("Failed to create config hash table!"); + return ; + } + + ret = config_parse(CONF_FILE, load_config, NULL); + + if (ret < 0) { + _E("Failed to load %s, %d Use default value!", CONF_FILE, ret); + test_config_unload(); + } +} + +void test_config_unload() +{ + if (NULL != config_hash) { + g_hash_table_unref(config_hash); + config_hash = NULL; + } +} + +bool test_config_is_supported(const char *module) +{ + // if fail to load config file, all modules are supported as default. + //if ((NULL == module) || (NULL == config_hash) || (0 == g_hash_table_size(config_hash))) + if ((NULL == module) || (NULL == config_hash)) + return TRUE; + + return g_hash_table_contains(config_hash, module); +} diff --git a/src/auto-test/config.h b/src/auto-test/config.h new file mode 100644 index 0000000..f541dd7 --- /dev/null +++ b/src/auto-test/config.h @@ -0,0 +1,30 @@ +/* + * deviced + * + * Copyright (c) 2014 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 __AUTOTEST_CONFIG_H__ +#define __AUTOTEST_CONFIG_H__ + +#include + +void test_config_load(const char *profile); +void test_config_unload(); +bool test_config_is_supported(const char *module); + + +#endif /* __AUTOTEST_CONFIG_H__ */ diff --git a/src/auto-test/main.c b/src/auto-test/main.c new file mode 100644 index 0000000..a3c8df7 --- /dev/null +++ b/src/auto-test/main.c @@ -0,0 +1,75 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ + +#include "test.h" +#include "config.h" + +static void test_main(int argc, char **argv) +{ + _I("auto test all"); + test_init((void *)NULL); + test_exit((void *)NULL); +} + +static void unit_test(int argc, char **argv) +{ + const struct test_ops *ops; + + ops = find_test(argv[2]); + if (!ops) { + _E("there is no test ops : %s", argv[2]); + return; + } + ops->unit(argc, argv); +} + +void show_usage() +{ + printf("Usage: deviced-auto-test [PROFILE] [MODULE] [UNIT-METHOD] [OPTS]\n\n"); + printf("Mandatory arguments\n"); + printf("[PROFILE] :\n"); + printf("\tmobile\n\twearable\n\ttv\n\tivi\n\tcommon\n\n"); + printf("Optional arguments\nIf you don't give any optional arguments, all supported modules will be tested.\n"); + printf("All module list is as below.\nAs per profile, supported modules are different.\n"); + printf("[MODULE]:\n"); + printf("\tbattery\n"); + printf("[UNIT-METHOD], [OPTS]:\n"); + printf("\tThis is refered to module information.\n"); + printf("\tThis can not be used without [MODULE] argument.\n\n"); +} + +int main(int argc, char **argv) +{ + if (argc < 2) { + show_usage(); + return 0; + } + + test_config_load(argv[1]); + config_test(); + + if (argc >= 3) + unit_test(argc, argv); + else + test_main(argc, argv); + + test_config_unload(); + + return 0; +} + diff --git a/src/auto-test/result.c b/src/auto-test/result.c new file mode 100644 index 0000000..4476e2d --- /dev/null +++ b/src/auto-test/result.c @@ -0,0 +1,45 @@ +/* + * test + * + * Copyright (c) 2014 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. + */ + +#include +#include +#include + +#include "core/list.h" +#include "core/common.h" + +#ifdef ENABLE_TEST_DLOG +#define ENABLE_DLOG +#endif + +#define LOG_TAG "ATR" /* AUTO_TESTE_RESULT */ +#include "shared/log-macro.h" + +#define BUF_MAX 256 + +void _R(const char *format, ...) +{ + va_list args; + char buf[BUF_MAX]; + + va_start(args, format); + vsnprintf(buf, BUF_MAX, format, args); + va_end(args); + + _D("%s", buf); +} diff --git a/src/auto-test/test.c b/src/auto-test/test.c new file mode 100644 index 0000000..40b950f --- /dev/null +++ b/src/auto-test/test.c @@ -0,0 +1,83 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ + +#include "test.h" +#include "config.h" + +static dd_list *dd_head; + +void add_test(const struct test_ops *d) +{ + if (d->priority == TEST_PRIORITY_HIGH) + DD_LIST_PREPEND(dd_head, d); + else + DD_LIST_APPEND(dd_head, d); +} + +void remove_test(const struct test_ops *d) +{ + DD_LIST_REMOVE(dd_head, d); +} + +const struct test_ops *find_test(const char *name) +{ + dd_list *elem; + const struct test_ops *d; + + DD_LIST_FOREACH(dd_head, elem, d) { + if (!strcasecmp(d->name, name)) + return d; + } + return NULL; +} + +void config_test() +{ + dd_list *elem; + const struct test_ops *d; + + DD_LIST_FOREACH(dd_head, elem, d) { + if (!test_config_is_supported(d->name)) + DD_LIST_REMOVE(dd_head, d); + } +} + +void test_init(void *data) +{ + dd_list *elem; + const struct test_ops *d; + + _D("test module count(%d)", DD_LIST_LENGTH(dd_head)); + DD_LIST_FOREACH(dd_head, elem, d) { + _D("[%s] initialize", d->name); + if (d->init) + d->init(data); + } +} + +void test_exit(void *data) +{ + dd_list *elem; + const struct test_ops *d; + + DD_LIST_FOREACH(dd_head, elem, d) { + _D("[%s] deinitialize", d->name); + if (d->exit) + d->exit(data); + } +} diff --git a/src/auto-test/test.h b/src/auto-test/test.h new file mode 100644 index 0000000..33108ab --- /dev/null +++ b/src/auto-test/test.h @@ -0,0 +1,109 @@ +/* + * test + * + * Copyright (c) 2013 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 __TEST_H__ +#define __TEST_H__ +#include +#include +#include +#include + +#include "core/list.h" +#include "core/common.h" +#include "core/udev.h" +#include "shared/dbus.h" + +#ifdef ENABLE_TEST_DLOG +#define ENABLE_DLOG +#endif + +#define LOG_TAG "AUTO_TEST" +#include "shared/log-macro.h" + +#define TEST_WAIT_TIME_INTERVAL 2 +#define METHOD_SET_DEVICE "device_changed" + +enum test_priority { + TEST_PRIORITY_NORMAL = 0, + TEST_PRIORITY_HIGH, +}; + +struct test_ops { + enum test_priority priority; + char *name; + void (*init) (void *data); + void (*exit) (void *data); + int (*start) (void); + int (*stop) (void); + int (*status) (void); + int (*unit) (int argc, char **argv); +}; + +enum test_ops_status { + TEST_OPS_STATUS_UNINIT, + TEST_OPS_STATUS_START, + TEST_OPS_STATUS_STOP, + TEST_OPS_STATUS_MAX, +}; + +void test_init(void *data); +void test_exit(void *data); + +static inline int test_start(const struct test_ops *c) +{ + if (c && c->start) + return c->start(); + + return -EINVAL; +} + +static inline int test_stop(const struct test_ops *c) +{ + if (c && c->stop) + return c->stop(); + + return -EINVAL; +} + +static inline int test_get_status(const struct test_ops *c) +{ + if (c && c->status) + return c->status(); + + return -EINVAL; +} + +#define TEST_OPS_REGISTER(c) \ +static void __CONSTRUCTOR__ module_init(void) \ +{ \ + add_test(c); \ +} \ +static void __DESTRUCTOR__ module_exit(void) \ +{ \ + remove_test(c); \ +} +DBusMessage *deviced_dbus_method_sync_with_reply(const char *dest, const char *path, + const char *interface, const char *method, + const char *sig, char *param[]); +void add_test(const struct test_ops *c); +void remove_test(const struct test_ops *c); +const struct test_ops *find_test(const char *name); +void config_test(); +void _R (const char *format, ...); +#endif -- 2.7.4 From c85563cb4c4190301b6d319202ba45eb3e866bcf Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Wed, 14 Jun 2017 18:50:56 +0900 Subject: [PATCH 06/16] auto-test: support display dbus test Change-Id: I5cb314c3127151ee1b338e0bdcfe990dbc10c89f Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 + src/auto-test/config.c | 2 +- src/auto-test/display.c | 651 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 658 insertions(+), 1 deletion(-) create mode 100644 src/auto-test/display.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index 6ca20db..ccdbe87 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -23,6 +23,7 @@ SET(SRCS config.c battery.c + display.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index f4fe9c7..2235891 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -1,14 +1,19 @@ [mobile] battery=1 +display=1 [wearable] battery=1 +display=1 [tv] battery=0 +display=1 [ivi] battery=0 +display=1 [common] battery=0 +display=1 diff --git a/src/auto-test/config.c b/src/auto-test/config.c index fb2acd8..b5c8b0f 100644 --- a/src/auto-test/config.c +++ b/src/auto-test/config.c @@ -60,7 +60,7 @@ void test_config_load(const char *profile) if (NULL != config_hash) test_config_unload(); - config_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); + config_hash = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL); if (NULL == config_hash) { _E("Failed to create config hash table!"); return ; diff --git a/src/auto-test/display.c b/src/auto-test/display.c new file mode 100644 index 0000000..0609c83 --- /dev/null +++ b/src/auto-test/display.c @@ -0,0 +1,651 @@ +/* + * test + * + * Copyright (c) 2016 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. + */ +#include +#include +#include + + +#include "test.h" + +#define METHOD_DISPLAY_GETBRIGHTNESS "getbrightness" +#define METHOD_DISPLAY_SETBRIGHTNESS "setbrightness" +#define METHOD_DISPLAY_GETMAXBRIGHTNESS "GetMaxBrightness" +#define METHOD_DISPLAY_SETMAXBRIGHTNESS "SetMaxBrightness" +#define METHOD_DISPLAY_HOLDBRIGHTNESS "HoldBrightness" +#define METHOD_DISPLAY_RELEASEBRIGHTNESS "ReleaseBrightness" +#define METHOD_DISPLAY_CUSTOMBRIGHTNESS "CustomBrightness" +#define METHOD_DISPLAY_SETAUTOBRIGHTNESSMIN "setautobrightnessmin" +#define METHOD_DISPLAY_SETREFRESHRATE "SetRefreshRate" +#define METHOD_DISPLAY_GETDISPLAYCOUNT "GetDisplayCount" +#define METHOD_DISPLAY_CHANGESTATE "ChangeState" +#define METHOD_DISPLAY_LOCKSTATE_NOPT "lockstate_nopt" +#define METHOD_DISPLAY_UNLOCKSTATE "unlockstate" +#define METHOD_DISPLAY_SETLCDTIMEOUT "setlcdtimeout" +#define METHOD_DISPLAY_CUSTOMLCDON "CustomLCDOn" +#define METHOD_DISPLAY_LCDPANEL_OFFMODE "LCDPanelOffMode" +#define METHOD_DISPLAY_STAYTOUCHSCREEN_OFF "StayTouchScreenOff" +#define METHOD_DISPLAY_LOCKSCREENBGON "LockScreenBgOn" +#define METHOD_DISPLAY_DUMPMODE "Dumpmode" +#define METHOD_DISPLAY_SAVELOG "SaveLog" +#define METHOD_DISPLAY_POWERKEY_IGNORE "PowerKeyIgnore" +#define METHOD_DISPLAY_POWERKEY_LCDOFF "PowerKeyLCDOff" +#define METHOD_DISPLAY_LOCKTIMEOUT_EXPIRED "LockTimeoutExpired" +#define METHOD_DISPLAY_LOCKTIMEOUT_INPUT "LockTimeoutInput" +#define METHOD_DISPLAY_ACTORCONTROL "ActorControl" +#define METHOD_DISPLAY_START "start" +#define METHOD_DISPLAY_STOP "stop" + +#define PM_STATE_LOG_FILE tzplatform_mkpath(TZ_SYS_ALLLOGS, "pm_state.log") + +static bool get_display_method(const char *method, int *value) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + method, NULL, NULL); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + _I("success (%s): %d", method, val); + ret = TRUE; + if (NULL != value) + *value = val; + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_display_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_display_method_noreply(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return FALSE; + } + + dbus_message_unref(msg); + return TRUE; +} + +static bool get_display_brightness(int *brightness) +{ + return get_display_method(METHOD_DISPLAY_GETBRIGHTNESS, brightness); +} + +static bool set_display_brightness(int brightness) +{ + DBusMessage *msg; + int getbrightness = -1; + int val = 0; + char *param[1]; + char str_val[10]; + bool ret = FALSE; + + snprintf(str_val, sizeof(str_val), "%d", brightness); + param[0] = str_val; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_DISPLAY_SETBRIGHTNESS, "i", param); + if (!msg) { + _E("fail : no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) { + _E("fail : no message"); + goto out; + } + + if (0 != val) { //setbrightness fail + if ((brightness <= 0) && (val == -EPERM)) { + _I("success : can't set brightness (%d) lower than zero", brightness); + ret = TRUE; + } else if (val == -EPERM) { + _E("fail : please check display api capability or brightness_automatic setting."); + } else { + _E("fail : return fail %d", val); + } + goto out; + } else { + if (brightness <= 0) { + _E("fail : can't set brightness (%d) lower than zero, but returned success", brightness); + goto out; + } + } + + if (!get_display_brightness(&getbrightness)) { + _E("fail : can't get brightness"); + } else { + if (brightness == getbrightness) { + _I("success : %d", getbrightness); + ret = TRUE; + } else { + _E("fail : set brightness %d, but current brightness is %d", brightness, getbrightness); + } + } +out: + dbus_message_unref(msg); + return ret; +} + +static bool get_display_maxbrightness() +{ + return get_display_method(METHOD_DISPLAY_GETMAXBRIGHTNESS, NULL); +} + +static bool set_display_maxbrightness(int brightness) +{ + char *param[1]; + char str_val[10]; + + snprintf(str_val, sizeof(str_val), "%d", brightness); + param[0] = str_val; + + return set_display_method(METHOD_DISPLAY_SETMAXBRIGHTNESS, "i", param); +} + +static bool set_display_holdbrightness(int brightness) +{ + char *param[1]; + char str_val[10]; + + snprintf(str_val, sizeof(str_val), "%d", brightness); + param[0] = str_val; + + return set_display_method(METHOD_DISPLAY_HOLDBRIGHTNESS, "i", param); +} + +static bool set_display_releasebrightness() +{ + return set_display_method(METHOD_DISPLAY_RELEASEBRIGHTNESS, NULL, NULL); +} + +static bool get_display_custombrightness() +{ + return get_display_method(METHOD_DISPLAY_CUSTOMBRIGHTNESS, NULL); +} + +static bool set_display_autobrightness_min(int min) +{ + DBusMessage *msg; + int val = 0; + char *param[1]; + char str_min[10]; + bool ret = FALSE; + + snprintf(str_min, sizeof(str_min), "%d", min); + param[0] = str_min; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_DISPLAY_SETAUTOBRIGHTNESSMIN, "i", param); + if (!msg) { + _E("fail : no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) { + _E("fail : no message"); + } else { + if ((min < 1) || (min > 100)) { + if (val < 0) { + _I("success : autobrightness min value should be 1~100. can't set (%d).", min); + ret = TRUE; + } else { + _I("fail : can't set (%d). but returned success", min); + } + } else { + if (val < 0) { + _E("fail : return fail (%d)", val); + } else { + _I("success : %d", val); + ret = TRUE; + } + } + } + dbus_message_unref(msg); + return ret; +} + +static bool set_display_refreshrate(int app, int rate) +{ + char *param[2]; + char str_app[10]; + char str_rate[10]; + + snprintf(str_app, sizeof(str_app), "%d", app); + snprintf(str_rate, sizeof(str_rate), "%d", rate); + + param[0] = str_app; + param[1] = str_rate; + + return set_display_method(METHOD_DISPLAY_SETREFRESHRATE, "ii", param); +} + +static bool get_display_count() +{ + return get_display_method(METHOD_DISPLAY_GETDISPLAYCOUNT, NULL); +} + +static bool set_display_changestate(char *state) +{ + char *param[1]; + + param[0] = state; + + return set_display_method(METHOD_DISPLAY_CHANGESTATE, "s", param); +} + +static bool set_display_lockstate_nopt(char *state, char *option, char *ignore, int timeout) +{ + char *param[4]; + char str_timeout[10]; + + snprintf(str_timeout, sizeof(str_timeout), "%d", timeout); + + param[0] = state; + param[1] = option; + param[1] = ignore; + param[1] = str_timeout; + + return set_display_method(METHOD_DISPLAY_LOCKSTATE_NOPT, "sssi", param); +} + +static bool set_display_unlockstate(char *state, char *option) +{ + char *param[2]; + + param[0] = state; + param[1] = option; + + return set_display_method(METHOD_DISPLAY_UNLOCKSTATE, "ss", param); +} + +static bool set_display_lcdtimeout(int normal, int dim, int holdkey_block) +{ + char *param[3]; + char str_normal[10]; + char str_dim[10]; + char str_holdkey[10]; + + snprintf(str_normal, sizeof(str_normal), "%d", normal); + snprintf(str_dim, sizeof(str_dim), "%d", dim); + snprintf(str_holdkey, sizeof(str_holdkey), "%d", holdkey_block); + + param[0] = str_normal; + param[1] = str_dim; + param[2] = str_holdkey; + + return set_display_method(METHOD_DISPLAY_SETLCDTIMEOUT, "iii", param); +} + +static bool set_display_customlcdon(int timeout_msec) +{ + char *param[3]; + char str_timeout[10]; + + snprintf(str_timeout, sizeof(str_timeout), "%d", timeout_msec); + + param[0] = str_timeout; + + return set_display_method(METHOD_DISPLAY_CUSTOMLCDON, "i", param); +} + +static bool set_display_lcdpanel_offmode(int on) +{ + char *param[1]; + char str_on[10]; + + snprintf(str_on, sizeof(str_on), "%d", on); + param[0] = str_on; + + return set_display_method(METHOD_DISPLAY_LCDPANEL_OFFMODE, "i", param); +} + +static bool set_display_staytouchscreen_off(int on) +{ + char *param[1]; + char str_on[10]; + + snprintf(str_on, sizeof(str_on), "%d", on); + param[0] = str_on; + + return set_display_method(METHOD_DISPLAY_STAYTOUCHSCREEN_OFF, "i", param); +} + +static bool set_display_lockscreen_bg_on(char *on) +{ + char *param[1]; + + param[0] = on; + + return set_display_method(METHOD_DISPLAY_LOCKSCREENBGON, "s", param); +} + +static bool set_display_dumpmode(char *on) +{ + char *param[1]; + + param[0] = on; + + return set_display_method(METHOD_DISPLAY_DUMPMODE, "s", param); +} + +static bool set_display_savelog() +{ + DBusMessage *msg; + struct stat buf; + bool ret = FALSE; + + if (!stat(PM_STATE_LOG_FILE, &buf)) { + remove(PM_STATE_LOG_FILE); + } + + if (!set_display_method_noreply(METHOD_DISPLAY_SAVELOG, NULL, NULL)) + return ret; + + sleep(3); + + if (!stat(PM_STATE_LOG_FILE, &buf)) { + _I("success : %s", PM_STATE_LOG_FILE); + ret = TRUE; + } + + return ret; +} + +static bool set_display_powerkey_ignore(int on) +{ + char *param[1]; + char str_on[10]; + + snprintf(str_on, sizeof(str_on), "%d", on); + param[0] = str_on; + + return set_display_method(METHOD_DISPLAY_POWERKEY_IGNORE, "i", param); +} + +static bool set_display_powerkey_lcdoff() +{ + return set_display_method(METHOD_DISPLAY_POWERKEY_LCDOFF, NULL, NULL); +} + +static bool set_display_locktimeout_expired(char *req_id) +{ + DBusMessage *msg; + char *param[1]; + int val; + char *ret_req_id; + bool ret = FALSE; + + param[0] = req_id; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_DISPLAY, + DEVICED_INTERFACE_DISPLAY, + METHOD_DISPLAY_LOCKTIMEOUT_EXPIRED, "s", param); + if (!msg) { + _E("fail: no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, + DBUS_TYPE_STRING, &ret_req_id, //request id + DBUS_TYPE_INT32, &val, //return value + DBUS_TYPE_INVALID) == 0) + _E("fail: no message"); + else { + if ((0 != strcmp(req_id, ret_req_id)) || (val < 0)) { + _E("fail: return fail"); + } else { + _I("success: %s %d", ret_req_id, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_display_locktimeout_input(char *req_id, int input) +{ + char *param[2]; + char str_input[10]; + + snprintf(str_input, sizeof(str_input), "%d", input); + param[0] = req_id; + param[1] = str_input; + + return set_display_method(METHOD_DISPLAY_LOCKTIMEOUT_INPUT, "si", param); +} + +static bool set_display_actorcontrol(char *command, int actor, int caps) +{ + char *param[3]; + char str_actor[10]; + char str_caps[10]; + + snprintf(str_actor, sizeof(str_actor), "%d", actor); + snprintf(str_caps, sizeof(str_caps), "%d", caps); + param[0] = command; + param[1] = str_actor; + param[2] = str_caps; + + return set_display_method(METHOD_DISPLAY_ACTORCONTROL, "sii", param); +} + +static bool set_display_start() +{ + return set_display_method_noreply(METHOD_DISPLAY_START, NULL, NULL); +} + +static bool set_display_stop() +{ + return set_display_method_noreply(METHOD_DISPLAY_STOP, NULL, NULL); +} + +void display_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (get_display_brightness(NULL)) ? s++ : f++; + (set_display_brightness(67)) ? s++ : f++; + (set_display_brightness(0)) ? s++ : f++; + (get_display_maxbrightness()) ? s++ : f++; + (set_display_maxbrightness(80)) ? s++ : f++; //not support, always success. + (set_display_holdbrightness(30)) ? s++ : f++; + (set_display_releasebrightness()) ? s++ : f++; + (get_display_custombrightness()) ? s++ : f++; + (set_display_autobrightness_min(15)) ? s++ : f++; + (set_display_autobrightness_min(0)) ? s++ : f++; + (set_display_refreshrate(0, 30)) ? s++ : f++; + (get_display_count()) ? s++ : f++; + (set_display_changestate("lcdon")) ? s++ : f++; + //(set_display_lockstate_nopt("lcddim", "staycurstate", "", 3)) ? s++ : f++; + //(set_display_unlockstate("lcddim", "resettimer")) ? s++ : f++; + (set_display_lcdtimeout(5, 10, 1)) ? s++ : f++; + (set_display_customlcdon(6000)) ? s++ : f++; + (set_display_lcdpanel_offmode(1)) ? s++ : f++; + (set_display_lcdpanel_offmode(0)) ? s++ : f++; + (set_display_staytouchscreen_off(1)) ? s++ : f++; + (set_display_staytouchscreen_off(0)) ? s++ : f++; + (set_display_lockscreen_bg_on("true")) ? s++ : f++; + (set_display_dumpmode("on")) ? s++ : f++; + (set_display_dumpmode("off")) ? s++ : f++; + (set_display_savelog()) ? s++ : f++; + (set_display_powerkey_ignore(1)) ? s++ : f++; //not support, always success. + (set_display_powerkey_lcdoff()) ? s++ : f++; //not support, always success. + //(set_display_locktimeout_expired("auto_test")) ? s++ : f++; + //(set_display_locktimeout_input("auto_test", 1)) ? s++ : f++; + (set_display_actorcontrol("set", 4, 1<<3)) ? s++ : f++; + (set_display_actorcontrol("reset", 4, 1<<3)) ? s++ : f++; + (set_display_stop()) ? s++ : f++; + (set_display_start()) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void display_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + display_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void display_exit(void *data) +{ + _I("end test"); + +} + +static int display_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + _I("start test"); + display_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_GETBRIGHTNESS)) { + get_display_brightness(NULL); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SETBRIGHTNESS)) { + set_display_brightness(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_GETMAXBRIGHTNESS)) { + get_display_maxbrightness(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SETMAXBRIGHTNESS)) { + set_display_maxbrightness(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_HOLDBRIGHTNESS)) { + set_display_holdbrightness(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_RELEASEBRIGHTNESS)) { + set_display_releasebrightness(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_CUSTOMBRIGHTNESS)) { + get_display_custombrightness(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SETAUTOBRIGHTNESSMIN)) { + set_display_autobrightness_min(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SETREFRESHRATE)) { + set_display_refreshrate(atoi(argv[4]), atoi(argv[5])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_GETDISPLAYCOUNT)) { + get_display_count(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_CHANGESTATE)) { + set_display_changestate(argv[4]); +// } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_LOCKSTATE_NOPT)) { +// set_display_lockstate_nopt(argv[4], argv[5], argv[6], atoi(argv[7])); +// } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_UNLOCKSTATE)) { +// set_display_lockstate_nopt(argv[4], argv[5]); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SETLCDTIMEOUT)) { + set_display_lcdtimeout(atoi(argv[4]), atoi(argv[5]), atoi(argv[6])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_CUSTOMLCDON)) { + set_display_customlcdon(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_LCDPANEL_OFFMODE)) { + set_display_lcdpanel_offmode(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_STAYTOUCHSCREEN_OFF)) { + set_display_staytouchscreen_off(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_LOCKSCREENBGON)) { + set_display_lockscreen_bg_on(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_DUMPMODE)) { + set_display_dumpmode(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_SAVELOG)) { + set_display_savelog(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_POWERKEY_IGNORE)) { + set_display_powerkey_ignore(atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_POWERKEY_LCDOFF)) { + set_display_powerkey_lcdoff(); +// } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_LOCKTIMEOUT_EXPIRED)) { +// set_display_locktimeout_expired(argv[4]); +// } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_LOCKTIMEOUT_INPUT)) { +// set_display_locktimeout_input(argv[4], atoi(argv[4])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_ACTORCONTROL)) { + set_display_actorcontrol(argv[4], atoi(argv[5]), atoi(argv[6])); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_START)) { + set_display_start(); + } else if (0 == strcasecmp(argv[3], METHOD_DISPLAY_STOP)) { + set_display_stop(); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops display_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "display", + .init = display_init, + .exit = display_exit, + .unit = display_unit, +}; + +TEST_OPS_REGISTER(&display_test_ops) -- 2.7.4 From 0563726e23bd61d4ff65a61fbec0015fec934c93 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Wed, 14 Jun 2017 23:01:28 +0900 Subject: [PATCH 07/16] Low battery : fix an issue that SYS_EVENT_BATTERY_LEVEL_STATUS is not updated Change-Id: I9d6ee7ae078082d633973507e4edf947a63f428b Signed-off-by: lokilee73 --- src/battery/lowbat-handler.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 src/battery/lowbat-handler.c diff --git a/src/battery/lowbat-handler.c b/src/battery/lowbat-handler.c old mode 100644 new mode 100755 index d1c2d68..e032c3c --- a/src/battery/lowbat-handler.c +++ b/src/battery/lowbat-handler.c @@ -492,7 +492,8 @@ int battery_charge_err_ovp_act(void *data) static void lowbat_scenario_init(void) { vconf_get_int(VCONF_KEY_BATTERY_WARNING_LEVEL, &custom_warning_level); - battery_info.warning = custom_warning_level; + if (custom_warning_level != BATTERY_UNKNOWN) + battery_info.warning = custom_warning_level; lowbat_add_scenario(battery_info.normal, battery_info.warning, battery_warning_low_act); lowbat_add_scenario(battery_info.normal, battery_info.critical, battery_critical_low_act); -- 2.7.4 From bc31e2f6ceafda375d8d5f5a0cdf8df3cdfb511f Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Thu, 15 Jun 2017 16:29:48 +0900 Subject: [PATCH 08/16] temperature : change interface from device-manager-plugin-xxx to pass When pass is enabled, the structure for thermal status has to be changed. Because temp data will be delivered from pass. It will be updated, when temp status is changed. Change-Id: I0b940b00d650198cdfcf333d622a360f227fb9f8 Signed-off-by: lokilee73 --- CMakeLists.txt | 3 + packaging/deviced.spec | 5 + src/thermal/thermal.c | 423 ++++++++++++++++++------------------------------- 3 files changed, 166 insertions(+), 265 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86e554e..02c971c 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,6 +230,9 @@ IF(USE_32BIT) ELSEIF(USE_64BIT) ADD_DEFINITIONS("-DARCH_64BIT") ENDIF() +IF(PASS STREQUAL on) + ADD_DEFINITIONS("-DPASS") +ENDIF() ADD_DEFINITIONS("-DDEBUG") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) diff --git a/packaging/deviced.spec b/packaging/deviced.spec index c994406..12becf9 100755 --- a/packaging/deviced.spec +++ b/packaging/deviced.spec @@ -189,6 +189,7 @@ pushd build_mobile -DTIZEN_FEATURE_CPU_MODULE=on \ -DTIZEN_FEATURE_TELEPHONY_MODULE=on \ -DTHERMAL_MODULE=on \ + -DPASS=on \ #eol popd @@ -219,6 +220,7 @@ pushd build_wearable -DTIZEN_FEATURE_CPU_MODULE=off \ -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ -DTHERMAL_MODULE=on \ + -DPASS=on \ #eol popd @@ -248,6 +250,7 @@ pushd build_tv -DTIZEN_FEATURE_CPU_MODULE=off \ -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ -DTHERMAL_MODULE=off \ + -DPASS=off \ #eol popd @@ -278,6 +281,7 @@ pushd build_common -DTIZEN_FEATURE_CPU_MODULE=off \ -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ -DTHERMAL_MODULE=off \ + -DPASS=off \ #eol popd @@ -309,6 +313,7 @@ pushd build_ivi -DTIZEN_FEATURE_CPU_MODULE=off \ -DTIZEN_FEATURE_TELEPHONY_MODULE=off \ -DTHERMAL_MODULE=off \ + -DPASS=off \ #eol popd diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index a87c4cd..657e331 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -28,80 +28,43 @@ #include "core/device-notifier.h" #include "core/devices.h" -static struct thermal_device *thermal_dev; static int noti; -#define ARRAY_SIZE(name) (sizeof(name)/sizeof(name[0])) +/* Core service: get/set device status operations about device */ +#ifdef PASS +#define THERMAL_PATH "/Org/Tizen/System/Pass/Monitor/Thermal" +#define THERMAL_INTERFACE "org.tizen.system.pass.monitor.thermal" +#define THERMAL_METHOD_TEMP_CHANGED "ChangedSiop" +#else +#define THERMAL_PATH "/Org/Tizen/Trm/Siop" +#define THERMAL_INTERFACE "org.tizen.trm.siop" +#define THERMAL_METHOD_TEMP_CHANGED "ChangedSiop" +#endif + #define SIGNAL_OVERHEAT_TIME "TimeUpdate" #define OVERHEAT_CALLBACK_TIME 1 //seconds #define OVERHEAT_POWEROFF_TIME 30 -enum thermal_trend_type { - NO_CHANGE, - LOW_TO_HIGH, - HIGH_TO_LOW, - HIGH_TO_HIGH -}; - -enum thermal_action_type { - NOTHING, +/* Temp level */ +#define LEVEL_DANGER "Danger" +#define LEVEL_CRITICAL "Critical" +#define LEVEL_HIGH "High" +#define LEVEL_LOW "Low" +#define LEVEL_NORMAL "Normal" + +/* Action type */ +#define SHUTDOWN_ACTION "ShutDownAction" +#define LIMIT_ACTION "LimitAction" +#define WARNING_ACTION "WarningAction" +#define RELEASE_ACTION "ReleaseAction" +#define NORMAL_ACTION "NormalAction" + +enum thermal_enum_type { + LOW, + NORMAL, WARNING, CRITICAL, - RECOVER -}; - -enum thermal_level_update_type { - UPDATE, - KEEP -}; - -struct thermal_state { - thermal_state_e old_state; - thermal_state_e new_state; - enum thermal_action_type status; -}; - -struct thermal_level { - thermal_level_e old_level; - thermal_level_e new_level; - enum thermal_action_type status; - enum thermal_level_update_type level; -}; - -static struct thermal_state temp_state[] = { - { THERMAL_STATE_LOW, THERMAL_STATE_LOW, NO_CHANGE}, - { THERMAL_STATE_LOW, THERMAL_STATE_NORMAL, NO_CHANGE}, - { THERMAL_STATE_LOW, THERMAL_STATE_HIGH, LOW_TO_HIGH}, - { THERMAL_STATE_NORMAL, THERMAL_STATE_LOW, NO_CHANGE}, - { THERMAL_STATE_NORMAL, THERMAL_STATE_NORMAL, NO_CHANGE}, - { THERMAL_STATE_NORMAL, THERMAL_STATE_HIGH, LOW_TO_HIGH}, - { THERMAL_STATE_HIGH, THERMAL_STATE_LOW, HIGH_TO_LOW}, - { THERMAL_STATE_HIGH, THERMAL_STATE_NORMAL, HIGH_TO_LOW}, - { THERMAL_STATE_HIGH, THERMAL_STATE_HIGH, HIGH_TO_HIGH} -}; - -static struct thermal_level lowhigh_temp_level[] = { - { THERMAL_LEVEL_NORMAL, THERMAL_LEVEL_WARNING, WARNING, UPDATE}, - { THERMAL_LEVEL_NORMAL, THERMAL_LEVEL_CRITICAL, CRITICAL, UPDATE}, - { THERMAL_LEVEL_NORMAL, THERMAL_LEVEL_POWEROFF, CRITICAL, UPDATE} -}; - -static struct thermal_level highlow_temp_level[] = { - { THERMAL_LEVEL_POWEROFF, THERMAL_LEVEL_NORMAL, NOTHING, KEEP}, - { THERMAL_LEVEL_CRITICAL, THERMAL_LEVEL_NORMAL, NOTHING, KEEP}, - { THERMAL_LEVEL_WARNING, THERMAL_LEVEL_NORMAL, RECOVER, UPDATE} -}; - -static struct thermal_level highhigh_temp_level[] = { - { THERMAL_LEVEL_WARNING, THERMAL_LEVEL_WARNING, NOTHING, UPDATE}, - { THERMAL_LEVEL_WARNING, THERMAL_LEVEL_CRITICAL, CRITICAL, UPDATE}, - { THERMAL_LEVEL_WARNING, THERMAL_LEVEL_POWEROFF, CRITICAL, UPDATE}, - { THERMAL_LEVEL_CRITICAL, THERMAL_LEVEL_WARNING, NOTHING, KEEP}, - { THERMAL_LEVEL_CRITICAL, THERMAL_LEVEL_CRITICAL, NOTHING, UPDATE}, - { THERMAL_LEVEL_CRITICAL, THERMAL_LEVEL_POWEROFF, NOTHING, UPDATE}, - { THERMAL_LEVEL_POWEROFF, THERMAL_LEVEL_WARNING, NOTHING, KEEP}, - { THERMAL_LEVEL_POWEROFF, THERMAL_LEVEL_CRITICAL, NOTHING, KEEP}, - { THERMAL_LEVEL_POWEROFF, THERMAL_LEVEL_POWEROFF, NOTHING, UPDATE} + DANGER }; static int power_off(void) @@ -115,128 +78,47 @@ static int power_off(void) return power->execute("poweroff"); } -static int thermal_state_check(int old_state, int new_state) -{ - int i, ret = -1; - - for (i = 0; i < ARRAY_SIZE(temp_state); i++) { - if (old_state == temp_state[i].old_state && - new_state == temp_state[i].new_state) { - ret = temp_state[i].status; - break; - } - } - - return ret; -} - -static void thermal_up_check(int old_level, int new_level, int *out_status, int *out_level) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(lowhigh_temp_level); i++) { - if (old_level == lowhigh_temp_level[i].old_level && - new_level == lowhigh_temp_level[i].new_level) { - *out_status = lowhigh_temp_level[i].status; - *out_level = lowhigh_temp_level[i].level; - break; - } - } -} - -static void thermal_down_check(int old_level, int new_level, int *out_status, int *out_level) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(highlow_temp_level); i++) { - if (old_level == highlow_temp_level[i].old_level && - new_level == highlow_temp_level[i].new_level) { - *out_status = highlow_temp_level[i].status; - *out_level = highlow_temp_level[i].level; - break; - } - } -} - -static void thermal_high_check(int old_level, int new_level, int *out_status, int *out_level) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(highhigh_temp_level); i++) { - if (old_level == highhigh_temp_level[i].old_level && - new_level == highhigh_temp_level[i].new_level) { - *out_status = highhigh_temp_level[i].status; - *out_level = highhigh_temp_level[i].level; - break; - } - } -} - static void thermal_remove_noti(void) { + int ret = 0; + if (noti) { - remove_notification("TempCooldownNotiOff", noti); - noti = 0; + ret = remove_notification("TempCooldownNotiOff", noti); + if (ret < 0) + _E("Fail to remove cooldown noti : %d", noti); + else + noti = 0; } } static void thermal_remove_popup(void) { - launch_system_app(APP_DEFAULT, 2, + int temp; + + temp = launch_system_app(APP_DEFAULT, 2, APP_KEY_TYPE, "remove_cooldown_popups"); + if (temp < 0) + _E("Fail to launch remove_cooldown_popups"); } static void thermal_add_noti(void) { + thermal_remove_noti(); if (!noti) noti = add_notification("TempCooldownNotiOn", NULL, NULL); } -static void broadcast_thermal_state_legacy(int state, int level) +static void broadcast_thermal_state_legacy(char *action_type) { - static int old = NOTHING; - int type; char *param[1]; - switch (state) { - case THERMAL_STATE_LOW: - case THERMAL_STATE_NORMAL: - type = NOTHING; - break; - case THERMAL_STATE_HIGH: - if (level == THERMAL_LEVEL_WARNING) - type = WARNING; - else if (level == THERMAL_LEVEL_CRITICAL || - level == THERMAL_LEVEL_POWEROFF) - type = CRITICAL; - else - type = NOTHING; - break; - default: - _E("Invalid state(%d)", state); - return; - } - - if (old == type) - return; - - switch (type) { - case NOTHING: - param[0] = "CoolDownRelease"; - break; - case WARNING: - param[0] = "WarningAction"; - break; - case CRITICAL: - param[0] = "LimitAction"; - break; - default: - _I("Invalid type (%d)", type); + if (!action_type) { + _E("Invalid action type"); return; } + param[0] = action_type; - old = type; - + _D("action_type = %s", param[0]); broadcast_edbus_signal(DEVICED_PATH_SYSNOTI, DEVICED_INTERFACE_SYSNOTI, "CoolDownChanged", @@ -270,7 +152,7 @@ static Eina_Bool thermal_overheat_time_broadcast(void *data) return ECORE_CALLBACK_RENEW; } -static void thermal_add_popup(void) +static void thermal_overheat_popup(void) { int ret; Ecore_Timer *timer; @@ -289,103 +171,125 @@ static void thermal_add_popup(void) static void thermal_add_recovery_popup(void) { - int ret; + int temp; - ret = launch_system_app(APP_DEFAULT, 2, + temp = launch_system_app(APP_DEFAULT, 2, APP_KEY_TYPE, "cooled_down"); - if (ret < 0) + if (temp < 0) _E("Fail to launch recovery popup"); } -static void thermal_action(struct thermal_info *info, void *data) +static int change_templevel_to_enum(char *string) { - static int old_state = -1, old_level = -1; - static int therm_state = -1, therm_action = -1, update = -1; + int temp = -1; - if (!info) - return; + if (!string) { + _E("Invalid temp level"); + return temp; + } + + if (!strncmp(string, LEVEL_NORMAL, strlen(LEVEL_NORMAL))) + temp = NORMAL; + else if (!strncmp(string, LEVEL_LOW, strlen(LEVEL_LOW))) + temp = LOW; + else if (!strncmp(string, LEVEL_HIGH, strlen(LEVEL_HIGH))) + temp = WARNING; + else if (!strncmp(string, LEVEL_CRITICAL, strlen(LEVEL_CRITICAL))) + temp = CRITICAL; + else if (!strncmp(string, LEVEL_DANGER, strlen(LEVEL_DANGER))) + temp = DANGER; + + return temp; +} - if (old_state < 0) { - old_state = info->state; - old_level = info->level; +static void thermal_action(char *state) +{ + static int old_state = NORMAL; + int new_state; + char *action = NULL; + + new_state = change_templevel_to_enum(state); + if (new_state < 0) { + _E("Invalid thermal state : %d", new_state); + goto out; } - therm_state = thermal_state_check(old_state, info->state); + _D("old_state = %d, new_state = %d", old_state, new_state); + if (old_state == DANGER) + goto out; - if (therm_state == NO_CHANGE) - update = UPDATE; - else if (therm_state == LOW_TO_HIGH) { - thermal_up_check(old_level, info->level, &therm_action, &update); - if (therm_action == WARNING) { - thermal_remove_noti(); - thermal_remove_popup(); - thermal_add_noti(); - } else if (therm_action == CRITICAL) { - thermal_remove_noti(); - thermal_remove_popup(); - thermal_add_popup(); - } - } else if (therm_state == HIGH_TO_LOW) { - thermal_down_check(old_level, info->level, &therm_action, &update); - if (therm_action == RECOVER) { - thermal_remove_popup(); + switch (new_state) { + case NORMAL: + case LOW: + if (old_state == WARNING || old_state == CRITICAL) { thermal_remove_noti(); thermal_add_recovery_popup(); - } - } else if (therm_state == HIGH_TO_HIGH) { - thermal_high_check(old_level, info->level, &therm_action, &update); - if (therm_action == CRITICAL) { - thermal_remove_noti(); - thermal_remove_popup(); - thermal_add_popup(); - } - } - - broadcast_thermal_state_legacy(info->state, info->level); + action = strdup(RELEASE_ACTION); + } else + action = strdup(NORMAL_ACTION); + break; - if (update == UPDATE) { - old_state = info->state; - old_level = info->level; - } + case WARNING: + thermal_remove_popup(); + thermal_add_noti(); + action = strdup(WARNING_ACTION); + break; - _I("Last old_state = %d old_level=%d", old_state, old_level); -} + case CRITICAL: + thermal_remove_popup(); + thermal_add_noti(); + action = strdup(LIMIT_ACTION); + break; -static int thermal_service_start(void) -{ - int ret; + case DANGER: + thermal_remove_popup(); + thermal_remove_noti(); + thermal_overheat_popup(); + action = strdup(SHUTDOWN_ACTION); + break; - if (!thermal_dev) { - _E("Thermal service is not supported"); - return -ENOTSUP; + default: + _E("invalid state : %d", new_state); + goto out; } - ret = thermal_dev->register_changed_event(thermal_action, NULL); - if (ret < 0) - _E("Failed to register thermal event (%d)", ret); + old_state = new_state; + broadcast_thermal_state_legacy(action); + free(action); - return ret; +out: + _D("Last old_state = %d, new_state = %d", old_state, new_state); } -static int thermal_service_stop(void) +static void temp_signal_handler(void *data, DBusMessage *msg) { - int ret; + DBusError err; + char *temp_str = NULL; - if (!thermal_dev) { - _E("Thermal service is not supported"); - return -ENOTSUP; + if (dbus_message_is_signal(msg, THERMAL_INTERFACE, THERMAL_METHOD_TEMP_CHANGED) == 0) { + _E("The signal is not for temp changed"); + return; } - ret = thermal_dev->unregister_changed_event(thermal_action); - if (ret < 0) - _E("Failed to unregister thermal event (%d)", ret); + dbus_error_init(&err); + + if (dbus_message_get_args(msg, &err, + DBUS_TYPE_STRING, &temp_str, + DBUS_TYPE_INVALID) == 0) { + _E("Failed to get temperature info"); + dbus_error_free(&err); + return; + } + dbus_error_free(&err); - return ret; + _D("temp_str = %s", temp_str); + thermal_action(temp_str); } static int booting_done(void *data) { static int done; + int ret; if (data == NULL) return done; @@ -394,55 +298,44 @@ static int booting_done(void *data) return done; _I("booting done"); - thermal_service_start(); + ret = register_edbus_signal_handler(THERMAL_PATH, + THERMAL_INTERFACE, + THERMAL_METHOD_TEMP_CHANGED, + temp_signal_handler); + if (ret < 0) + _E("Fail to register sig handler for temperature"); return done; } static void thermal_init(void *data) { - register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); -} + int ret; -static void thermal_exit(void *data) -{ - unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); - thermal_service_stop(); + ret = register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); + if (ret < 0) + _E("Fail to register booting done Notifier"); } -static int thermal_probe(void *data) +static void thermal_exit(void *data) { - struct hw_info *info; int ret; - if (thermal_dev) - return 0; - - ret = hw_get_info(THERMAL_HARDWARE_DEVICE_ID, - (const struct hw_info **)&info); - if (ret < 0) { - _E("There is no HAL for Thermal"); - return ret; - } - - if (!info->open) { - _E("Failed to open thermal device; open(NULL)"); - return -ENODEV; - } + ret = unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done); + if (ret < 0) + _E("Fail to unregister booting done Notifier"); - ret = info->open(info, NULL, (struct hw_common**)&thermal_dev); - if (ret < 0) { - _E("Failed to get thermal device structure (%d)", ret); - return ret; + ret = unregister_edbus_signal_handler(THERMAL_PATH, + THERMAL_INTERFACE, + THERMAL_METHOD_TEMP_CHANGED); + if (ret < 0) + _E("Fail to unregister sig handler for temperature"); } - if (!thermal_dev || - !thermal_dev->get_state || - !thermal_dev->register_changed_event || - !thermal_dev->unregister_changed_event) { - _E("Thermal HAL does not support event handler"); - return -ENODEV; - } +static int thermal_probe(void *data) +{ + /* device-manager-plugin-xxx is not used for the information of temperature. + instead, pass is used */ _I("Thermal device structure load success"); return 0; -- 2.7.4 From 06e55accaf2aaa5e3a8d0a9346cde3cf748e3253 Mon Sep 17 00:00:00 2001 From: lokilee73 Date: Mon, 19 Jun 2017 17:25:37 +0900 Subject: [PATCH 09/16] overheat popup : add remove_overheat_popups before powering off Change-Id: I2884753104d18d9eb66b22189a82be82283a0026 Signed-off-by: lokilee73 --- src/thermal/thermal.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/thermal/thermal.c b/src/thermal/thermal.c index 657e331..de8c06e 100755 --- a/src/thermal/thermal.c +++ b/src/thermal/thermal.c @@ -144,6 +144,11 @@ static Eina_Bool thermal_overheat_time_broadcast(void *data) time -= 1; if (time < 0) { time = OVERHEAT_POWEROFF_TIME; + ret = launch_system_app(APP_OVERHEAT, 2, + APP_KEY_TYPE, "remove_overheat_popups"); + if (ret < 0) + _E("Fail to remove overheat popups"); + ret = power_off(); if (ret < 0) _E("Fail to power off"); -- 2.7.4 From 57da31b8ba033eb831341aa43e0debbf0781affa Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Thu, 22 Jun 2017 10:49:56 +0200 Subject: [PATCH 10/16] usb-host-test: Add missing license information MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I652ddf5d17cc82133ed7244978ed6c5d6b405c92 Signed-off-by: Paweł Szewczyk --- src/usb-host-ffs-test-daemon/descs_gen.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/usb-host-ffs-test-daemon/descs_gen.c b/src/usb-host-ffs-test-daemon/descs_gen.c index fb1dca1..34e56ff 100644 --- a/src/usb-host-ffs-test-daemon/descs_gen.c +++ b/src/usb-host-ffs-test-daemon/descs_gen.c @@ -1,3 +1,21 @@ +/* + * deviced + * + * Copyright (c) 2017 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. + */ + #include #include #include -- 2.7.4 From 39ff1e0fff8ed2fe9b03103087d524237e1bfbb6 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 23 Jun 2017 14:18:36 +0900 Subject: [PATCH 11/16] auto-test: support led dbus test Change-Id: I6ce61c35e007ec453e192a47a1177d024b5ab749 Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 + src/auto-test/led.c | 222 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 228 insertions(+) create mode 100755 src/auto-test/led.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index ccdbe87..4df5ef4 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -24,6 +24,7 @@ SET(SRCS battery.c display.c + led.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index 2235891..e01cc6c 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -1,19 +1,24 @@ [mobile] battery=1 display=1 +led=1 [wearable] battery=1 display=1 +led=0 [tv] battery=0 display=1 +led=0 [ivi] battery=0 display=1 +led=0 [common] battery=0 display=1 +led=0 diff --git a/src/auto-test/led.c b/src/auto-test/led.c new file mode 100755 index 0000000..3353d25 --- /dev/null +++ b/src/auto-test/led.c @@ -0,0 +1,222 @@ +/* + * test + * + * Copyright (c) 2015 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 uynder the License. + */ + + +#include "test.h" +#include + +#define METHOD_LED_SETIRCOMMAND "SetIrCommand" +#define METHOD_LED_PLAYCUSTOM "playcustom" +#define METHOD_LED_STOPCUSTOM "stopcustom" +//#define METHOD_LED_GETBRIGHTNESS_FORCAMERA "GetBrightnessForCamera" +#define METHOD_LED_GETBRIGHTNESS "GetBrightness" +#define METHOD_LED_GETMAXBRIGHTNESS "GetMaxBrightness" +#define METHOD_LED_SETBRIGHTNESS "SetBrightness" + +#define RED 0xff0000 +#define GREEN 0x00ff00 +#define BLUE 0x0000ff +#define DEFAULT_FLAG (1 << 0) + +static bool get_led_method(const char *method) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + method, NULL, NULL); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_led_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool get_led_maxbrightness(void) +{ + return get_led_method(METHOD_LED_GETMAXBRIGHTNESS); +} + +static bool get_led_brightness(void) +{ + return get_led_method(METHOD_LED_GETBRIGHTNESS); +} + +static bool set_led_brightness(int brightness, int enabled) +{ + char *param[2]; + char str_brightness[10]; + char str_enabled[10]; + + snprintf(str_brightness, sizeof(str_brightness), "%d", brightness); + snprintf(str_enabled, sizeof(str_enabled), "%d", enabled); + param[0] = str_brightness; + param[1] = str_enabled; + + return set_led_method(METHOD_LED_SETBRIGHTNESS, "ii", param); +} + +static bool set_led_playcustom(int on, int off, unsigned int color, unsigned int flags) +{ + char *param[4]; + char str_on[10]; + char str_off[10]; + char str_color[10]; + char str_flags[10]; + + snprintf(str_on, sizeof(str_on), "%d", on); + snprintf(str_off, sizeof(str_off), "%d", off); + snprintf(str_color, sizeof(str_color), "%lu", (long unsigned int)color); + snprintf(str_flags, sizeof(str_flags), "%lu", (long unsigned int)flags); + param[0] = str_on; + param[1] = str_off; + param[2] = str_color; + param[3] = str_flags; + + return set_led_method(METHOD_LED_PLAYCUSTOM, "iiuu", param); +} + +static bool set_led_stopcustom() +{ + return set_led_method(METHOD_LED_STOPCUSTOM, NULL, NULL); +} + +static bool set_led_ircommand(char *command) +{ + char *param[1]; + + param[0] = command; + + return set_led_method(METHOD_LED_SETIRCOMMAND, "s", param); +} + +void led_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (get_led_maxbrightness()) ? s++ : f++; + (set_led_brightness(90, 1)) ? s++ : f++; + (set_led_brightness(0, 1)) ? s++ : f++; + (get_led_brightness()) ? s++ : f++; + (set_led_playcustom(1, 0, RED, DEFAULT_FLAG)) ? s++ : f++; + (set_led_stopcustom()) ? s++ : f++; + (set_led_ircommand("N/A")) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void led_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + led_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void led_exit(void *data) +{ + _I("end test"); +} + +static int led_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + _I("start test"); + led_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcasecmp(argv[3], METHOD_LED_GETMAXBRIGHTNESS)) { + get_led_maxbrightness(); + } else if (0 == strcasecmp(argv[3], METHOD_LED_GETBRIGHTNESS)) { + get_led_brightness(); + } else if (0 == strcasecmp(argv[3], METHOD_LED_SETBRIGHTNESS)) { + set_led_brightness(atoi(argv[4]), atoi(argv[5])); + } else if (0 == strcasecmp(argv[3], METHOD_LED_PLAYCUSTOM)) { + set_led_playcustom(atoi(argv[4]), atoi(argv[5]), strtoul(argv[6], NULL, 16), DEFAULT_FLAG); + } else if (0 == strcasecmp(argv[3], METHOD_LED_STOPCUSTOM)) { + set_led_stopcustom(); + } else if (0 == strcasecmp(argv[3], METHOD_LED_SETIRCOMMAND)) { + set_led_ircommand(argv[3]); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops led_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "led", + .init = led_init, + .exit = led_exit, + .unit = led_unit, +}; + +TEST_OPS_REGISTER(&led_test_ops) -- 2.7.4 From 5d5fcc1462489aabd5a775974a623982e584cd7b Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Tue, 27 Jun 2017 11:09:44 +0900 Subject: [PATCH 12/16] auto-test: support reboot dbus test Change-Id: Ie2e12eb5d7e2188115b5f8a21c8a56561c0e275d Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 ++ src/auto-test/reboot.c | 126 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 132 insertions(+) create mode 100755 src/auto-test/reboot.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index 4df5ef4..dc21311 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -25,6 +25,7 @@ SET(SRCS battery.c display.c led.c + reboot.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index e01cc6c..e984417 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -2,23 +2,28 @@ battery=1 display=1 led=1 +reboot=1 [wearable] battery=1 display=1 led=0 +reboot=1 [tv] battery=0 display=1 led=0 +reboot=1 [ivi] battery=0 display=1 led=0 +reboot=1 [common] battery=0 display=1 led=0 +reboot=1 diff --git a/src/auto-test/reboot.c b/src/auto-test/reboot.c new file mode 100755 index 0000000..073f2a3 --- /dev/null +++ b/src/auto-test/reboot.c @@ -0,0 +1,126 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ +#include "test.h" + +#define METHOD_REBOOT "reboot" +#define METHOD_REBOOTWITHOPTION "RebootWithOption" +#define METHOD_REBOOT2 "Reboot" + +static bool set_reboot_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_REBOOT, + DEVICED_INTERFACE_REBOOT, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_reboot(char *type) +{ + char *param[2]; + char str_argc[10]; + + snprintf(str_argc, sizeof(str_argc), "%d", 0); + + param[0] = type; + param[1] = str_argc; + + return set_reboot_method(METHOD_REBOOT, "si", param); +} + +static bool set_reboot_with_option(char *type, char *option) +{ + char *param[2]; + + param[0] = type; + param[1] = option; + + return set_reboot_method(METHOD_REBOOTWITHOPTION, "ss", param); +} + +static bool set_Reboot() +{ + char *param[1]; + char str_param[10]; + + snprintf(str_param, sizeof(str_param), "%s", "not_used"); + + param[0] = str_param; + + return set_reboot_method(METHOD_REBOOT2, "s", param); +} + +static void reboot_init(void *data) +{ + _I("There is no test!"); +} + +static void reboot_exit(void *data) +{ +} + +static int reboot_unit(int argc, char **argv) +{ + if (argc < 4) { + _I("There is no default test!"); + } else if (0 == strcmp(argv[3], METHOD_REBOOT)) { + set_reboot(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_REBOOTWITHOPTION)) { + set_reboot_with_option(argv[4], argv[5]); + } else if (0 == strcmp(argv[3], METHOD_REBOOT2)) { + set_Reboot(); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops reboot_test_ops = { + .priority = TEST_PRIORITY_HIGH, + .name = "reboot", + .init = reboot_init, + .exit = reboot_exit, + .unit = reboot_unit, +}; + +TEST_OPS_REGISTER(&reboot_test_ops) -- 2.7.4 From 8ebf7375c084ba13050f2faea0180a850462faca Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Tue, 27 Jun 2017 18:24:40 +0900 Subject: [PATCH 13/16] auto-test: support lowpower dbus test Change-Id: Ia6b74de6ad5507c5eefa9c70e7be09ba498712aa Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 2 +- src/auto-test/auto-test.conf | 10 +- src/auto-test/power.c | 223 +++++++++++++++++++++++++++++++++++++++++++ src/auto-test/reboot.c | 126 ------------------------ 4 files changed, 229 insertions(+), 132 deletions(-) create mode 100755 src/auto-test/power.c delete mode 100755 src/auto-test/reboot.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index dc21311..99b2e5a 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -25,7 +25,7 @@ SET(SRCS battery.c display.c led.c - reboot.c + power.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index e984417..00213a0 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -2,28 +2,28 @@ battery=1 display=1 led=1 -reboot=1 +power=1 [wearable] battery=1 display=1 led=0 -reboot=1 +power=1 [tv] battery=0 display=1 led=0 -reboot=1 +power=1 [ivi] battery=0 display=1 led=0 -reboot=1 +power=1 [common] battery=0 display=1 led=0 -reboot=1 +power=1 diff --git a/src/auto-test/power.c b/src/auto-test/power.c new file mode 100755 index 0000000..892ba4c --- /dev/null +++ b/src/auto-test/power.c @@ -0,0 +1,223 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ +#include "test.h" + +#define METHOD_REBOOT "reboot" +#define METHOD_REBOOTWITHOPTION "RebootWithOption" +#define METHOD_REBOOT2 "Reboot" + +#define METHOD_LOWPOWER_START "Start" +#define METHOD_LOWPOWER_STOP "Stop" +#define METHOD_LOWPOWER_GETSTATE "GetState" + +static bool set_reboot_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_REBOOT, + DEVICED_INTERFACE_REBOOT, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_reboot(char *type) +{ + char *param[2]; + char str_argc[10]; + + snprintf(str_argc, sizeof(str_argc), "%d", 0); + + param[0] = type; + param[1] = str_argc; + + return set_reboot_method(METHOD_REBOOT, "si", param); +} + +static bool set_reboot_with_option(char *type, char *option) +{ + char *param[2]; + + param[0] = type; + param[1] = option; + + return set_reboot_method(METHOD_REBOOTWITHOPTION, "ss", param); +} + +static bool set_Reboot() +{ + char *param[1]; + char str_param[10]; + + snprintf(str_param, sizeof(str_param), "%s", "not_used"); + + param[0] = str_param; + + return set_reboot_method(METHOD_REBOOT2, "s", param); +} + +static bool request_lowpower_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + int retry = 0; + + while (retry++ < 3) { + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_LOWPOWER, + DEVICED_INTERFACE_LOWPOWER, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if (val == -EAGAIN) { + dbus_message_unref(msg); + _I("wait! will try again! (%s): %d", method, val); + sleep(3); + continue; + } else if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + dbus_message_unref(msg); + break; + } + + return ret; +} + +static bool set_lowpower_start() +{ + return request_lowpower_method(METHOD_LOWPOWER_START, NULL, NULL); +} + +static bool set_lowpower_stop() +{ + return request_lowpower_method(METHOD_LOWPOWER_STOP, NULL, NULL); +} + +static bool set_lowpower_getstate() +{ + return request_lowpower_method(METHOD_LOWPOWER_GETSTATE, NULL, NULL); +} + +void lowpower_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (set_lowpower_start()) ? s++ : f++; + (set_lowpower_stop()) ? s++ : f++; + (set_lowpower_getstate()) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void power_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + lowpower_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void power_exit(void *data) +{ + _I("end test"); +} + +static int power_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + + _I("start test"); + lowpower_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcmp(argv[3], METHOD_REBOOT)) { + set_reboot(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_REBOOTWITHOPTION)) { + set_reboot_with_option(argv[4], argv[5]); + } else if (0 == strcmp(argv[3], METHOD_REBOOT2)) { + set_Reboot(); + } else if (0 == strcasecmp(argv[3], "lowpower")) { + if (0 == strcasecmp(argv[4], METHOD_LOWPOWER_START)) { + set_lowpower_start(); + } else if (0 == strcasecmp(argv[4], METHOD_LOWPOWER_STOP)) { + set_lowpower_stop(); + } else if (0 == strcasecmp(argv[4], METHOD_LOWPOWER_GETSTATE)) { + set_lowpower_getstate(); + } else { + _E("Unknown test case!!!"); + } + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops power_test_ops = { + .priority = TEST_PRIORITY_HIGH, + .name = "power", + .init = power_init, + .exit = power_exit, + .unit = power_unit, +}; + +TEST_OPS_REGISTER(&power_test_ops) diff --git a/src/auto-test/reboot.c b/src/auto-test/reboot.c deleted file mode 100755 index 073f2a3..0000000 --- a/src/auto-test/reboot.c +++ /dev/null @@ -1,126 +0,0 @@ -/* - * test - * - * Copyright (c) 2013 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. - */ -#include "test.h" - -#define METHOD_REBOOT "reboot" -#define METHOD_REBOOTWITHOPTION "RebootWithOption" -#define METHOD_REBOOT2 "Reboot" - -static bool set_reboot_method(const char *method, char *sig, char *param[]) -{ - DBusMessage *msg; - int val; - bool ret = FALSE; - - msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, - DEVICED_PATH_REBOOT, - DEVICED_INTERFACE_REBOOT, - method, sig, param); - if (!msg) { - _E("fail (%s): no reply", method); - return ret; - } - - if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) - _E("fail (%s): no message", method); - else { - if ((val == -ENOTSUP) || (val == -ENOSYS)) { - _I("Not supported feature! (%s): %d", method, val); - ret = TRUE; - } else if (val < 0) { - _E("fail (%s): returned fail (%d)", method, val); - } else { - _I("success (%s): %d", method, val); - ret = TRUE; - } - } - - dbus_message_unref(msg); - return ret; -} - -static bool set_reboot(char *type) -{ - char *param[2]; - char str_argc[10]; - - snprintf(str_argc, sizeof(str_argc), "%d", 0); - - param[0] = type; - param[1] = str_argc; - - return set_reboot_method(METHOD_REBOOT, "si", param); -} - -static bool set_reboot_with_option(char *type, char *option) -{ - char *param[2]; - - param[0] = type; - param[1] = option; - - return set_reboot_method(METHOD_REBOOTWITHOPTION, "ss", param); -} - -static bool set_Reboot() -{ - char *param[1]; - char str_param[10]; - - snprintf(str_param, sizeof(str_param), "%s", "not_used"); - - param[0] = str_param; - - return set_reboot_method(METHOD_REBOOT2, "s", param); -} - -static void reboot_init(void *data) -{ - _I("There is no test!"); -} - -static void reboot_exit(void *data) -{ -} - -static int reboot_unit(int argc, char **argv) -{ - if (argc < 4) { - _I("There is no default test!"); - } else if (0 == strcmp(argv[3], METHOD_REBOOT)) { - set_reboot(argv[4]); - } else if (0 == strcasecmp(argv[3], METHOD_REBOOTWITHOPTION)) { - set_reboot_with_option(argv[4], argv[5]); - } else if (0 == strcmp(argv[3], METHOD_REBOOT2)) { - set_Reboot(); - } else { - _E("Unknown test case!!!"); - } - - return 0; -} - -static const struct test_ops reboot_test_ops = { - .priority = TEST_PRIORITY_HIGH, - .name = "reboot", - .init = reboot_init, - .exit = reboot_exit, - .unit = reboot_unit, -}; - -TEST_OPS_REGISTER(&reboot_test_ops) -- 2.7.4 From 7bd49ee3e0316bda4c83fd0b19c9c337c996fd56 Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Wed, 28 Jun 2017 15:44:48 +0900 Subject: [PATCH 14/16] auto-test: support proc dbus test Change-Id: I79a4108db5353b14cec7565d7b8724c5045b9aff Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 ++ src/auto-test/proc.c | 129 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 135 insertions(+) create mode 100755 src/auto-test/proc.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index 99b2e5a..da6da42 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -26,6 +26,7 @@ SET(SRCS display.c led.c power.c + proc.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index 00213a0..2e3dde8 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -3,27 +3,32 @@ battery=1 display=1 led=1 power=1 +proc=1 [wearable] battery=1 display=1 led=0 power=1 +proc=1 [tv] battery=0 display=1 led=0 power=1 +proc=1 [ivi] battery=0 display=1 led=0 power=1 +proc=1 [common] battery=0 display=1 led=0 power=1 +proc=1 diff --git a/src/auto-test/proc.c b/src/auto-test/proc.c new file mode 100755 index 0000000..8668c1a --- /dev/null +++ b/src/auto-test/proc.c @@ -0,0 +1,129 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ +#include "test.h" + +#define METHOD_PROC_OOMADJ_SET "oomadj_set" + +static bool set_proc_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_PROCESS, + DEVICED_INTERFACE_PROCESS, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_proc_oomadj(char *type, int argc, int pid, int score_adj) +{ + char *param[4]; + char str_argc[10]; + char str_pid[10]; + char str_score_adj[10]; + + snprintf(str_argc, sizeof(str_argc), "%d", argc); + snprintf(str_pid, sizeof(str_pid), "%d", pid); + snprintf(str_score_adj, sizeof(str_score_adj), "%d", score_adj); + + param[0] = type; + param[1] = str_argc; + param[2] = str_pid; + param[3] = str_score_adj; + + return set_proc_method(METHOD_PROC_OOMADJ_SET, "siss", param); +} + +void proc_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (set_proc_oomadj("oomadj_set", 2, getpid(), 300)) ? s++ : f++; + (set_proc_oomadj("oomadj_set", 2, getpid(), 100)) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void proc_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + proc_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void proc_exit(void *data) +{ + _I("end test"); +} + +static int proc_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + + _I("start test"); + proc_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcmp(argv[3], METHOD_PROC_OOMADJ_SET)) { + set_proc_oomadj(argv[4], atoi(argv[5]), atoi(argv[6]), atoi(argv[7])); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops proc_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "proc", + .init = proc_init, + .exit = proc_exit, + .unit = proc_unit, +}; + +TEST_OPS_REGISTER(&proc_test_ops) -- 2.7.4 From 6191fb8c8fcd4d493adbc88d5b749ec69a27a07e Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Thu, 29 Jun 2017 18:45:32 +0900 Subject: [PATCH 15/16] auto-test: support extcon dbus test Change-Id: I33885c7a81b10367f2364f4c5f0e8fdca1464da5 Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 ++ src/auto-test/extcon.c | 169 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 175 insertions(+) create mode 100755 src/auto-test/extcon.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index da6da42..e57e533 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -27,6 +27,7 @@ SET(SRCS led.c power.c proc.c + extcon.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index 2e3dde8..23c3a1b 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -4,6 +4,7 @@ display=1 led=1 power=1 proc=1 +extcon=1 [wearable] battery=1 @@ -11,6 +12,7 @@ display=1 led=0 power=1 proc=1 +extcon=1 [tv] battery=0 @@ -18,6 +20,7 @@ display=1 led=0 power=1 proc=1 +extcon=1 [ivi] battery=0 @@ -25,6 +28,7 @@ display=1 led=0 power=1 proc=1 +extcon=1 [common] battery=0 @@ -32,3 +36,4 @@ display=1 led=0 power=1 proc=1 +extcon=1 diff --git a/src/auto-test/extcon.c b/src/auto-test/extcon.c new file mode 100755 index 0000000..493d547 --- /dev/null +++ b/src/auto-test/extcon.c @@ -0,0 +1,169 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ +#include "test.h" + +#define METHOD_EXTCON_GETSTATUS "GetStatus" +#define METHOD_EXTCON_ENABLE "enable" +#define METHOD_EXTCON_DISABLE "disable" + +static bool request_extcon_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_EXTCON, + DEVICED_INTERFACE_EXTCON, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool get_extcon_status(char *device_name) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + char *param[1]; + + param[0] = device_name; + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_EXTCON, + DEVICED_INTERFACE_EXTCON, + METHOD_EXTCON_GETSTATUS, "s", param); + if (!msg) { + _E("fail : no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail : no message"); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! : %d", val); + ret = TRUE; + } else if ((val == -EINVAL) || (val == -ENOENT)) { + _E("fail : returned fail (%d)", val); + } else { + _I("success : %d", val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool set_extcon_enable(char *device_name) +{ + char *param[1]; + + param[0] = device_name; + return request_extcon_method(METHOD_EXTCON_ENABLE, "s", param); +} + +static bool set_extcon_disable(char *device_name) +{ + char *param[1]; + + param[0] = device_name; + return request_extcon_method(METHOD_EXTCON_DISABLE, "s", param); +} + + +void extcon_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + (set_extcon_enable("Headphone")) ? s++ : f++; + (get_extcon_status("Headphone")) ? s++ : f++; + (set_extcon_disable("Headphone")) ? s++ : f++; + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void extcon_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + extcon_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void extcon_exit(void *data) +{ + _I("end test"); +} + +static int extcon_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + + _I("start test"); + extcon_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcasecmp(argv[3], METHOD_EXTCON_GETSTATUS)) { + get_extcon_status(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_EXTCON_ENABLE)) { + set_extcon_enable(argv[4]); + } else if (0 == strcasecmp(argv[3], METHOD_EXTCON_DISABLE)) { + set_extcon_disable(argv[4]); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops extcon_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "extcon", + .init = extcon_init, + .exit = extcon_exit, + .unit = extcon_unit, +}; + +TEST_OPS_REGISTER(&extcon_test_ops) -- 2.7.4 From 8eb81bd1835f83c0763d7ed1b356026c1bf8c65a Mon Sep 17 00:00:00 2001 From: Yunmi Ha Date: Fri, 30 Jun 2017 13:59:12 +0900 Subject: [PATCH 16/16] auto-test: support ir dbus test Change-Id: I73dd2d414cbc046cb0c8ab26a4819a46fda4ed09 Signed-off-by: Yunmi Ha --- src/auto-test/CMakeLists.txt | 1 + src/auto-test/auto-test.conf | 5 ++ src/auto-test/ir.c | 185 +++++++++++++++++++++++++++++++++++++++++++ src/auto-test/led.c | 13 --- 4 files changed, 191 insertions(+), 13 deletions(-) create mode 100755 src/auto-test/ir.c diff --git a/src/auto-test/CMakeLists.txt b/src/auto-test/CMakeLists.txt index e57e533..d4f4b3c 100644 --- a/src/auto-test/CMakeLists.txt +++ b/src/auto-test/CMakeLists.txt @@ -28,6 +28,7 @@ SET(SRCS power.c proc.c extcon.c + ir.c ) # extcon test diff --git a/src/auto-test/auto-test.conf b/src/auto-test/auto-test.conf index 23c3a1b..077beae 100644 --- a/src/auto-test/auto-test.conf +++ b/src/auto-test/auto-test.conf @@ -5,6 +5,7 @@ led=1 power=1 proc=1 extcon=1 +ir=1 [wearable] battery=1 @@ -13,6 +14,7 @@ led=0 power=1 proc=1 extcon=1 +ir=0 [tv] battery=0 @@ -21,6 +23,7 @@ led=0 power=1 proc=1 extcon=1 +ir=0 [ivi] battery=0 @@ -29,6 +32,7 @@ led=0 power=1 proc=1 extcon=1 +ir=0 [common] battery=0 @@ -37,3 +41,4 @@ led=0 power=1 proc=1 extcon=1 +ir=0 diff --git a/src/auto-test/ir.c b/src/auto-test/ir.c new file mode 100755 index 0000000..49ed9c7 --- /dev/null +++ b/src/auto-test/ir.c @@ -0,0 +1,185 @@ +/* + * test + * + * Copyright (c) 2013 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. + */ +#include "test.h" + +#define METHOD_IR_ISAVAILABLE "IRIsAvailable" +#define METHOD_IR_TRANSMIT "TransmitIR" +#define METHOD_IR_SETIRCOMMAND "SetIrCommand" + +struct dbus_int { + int *list; + int size; +}; + +static bool request_ir_method(const char *method, char *sig, char *param[]) +{ + DBusMessage *msg; + int val; + bool ret = FALSE; + + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_IR, + DEVICED_INTERFACE_IR, + method, sig, param); + if (!msg) { + _E("fail (%s): no reply", method); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail (%s): no message", method); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! (%s): %d", method, val); + ret = TRUE; + } else if (val == -ENODEV) { + _E("fail (%s): device open fail (%d)", method, val); + } else if (val < 0) { + _E("fail (%s): returned fail (%d)", method, val); + } else { + _I("success (%s): %d", method, val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +static bool get_ir_isavailable() +{ + return request_ir_method(METHOD_IR_ISAVAILABLE, NULL, NULL); +} + +static bool set_ir_transmit(int carrier_frequency, int *pattern, int size) +{ + char *param[1]; + int freq_pattern[size + 1]; + struct dbus_int pattern_list; + + freq_pattern[0] = carrier_frequency; + for (int i = 1; i <= size; i++) + freq_pattern[i] = pattern[i-1]; + + pattern_list.list = freq_pattern; + pattern_list.size = size + 1; + + param[0] = (char *)&pattern_list; + return request_ir_method(METHOD_IR_TRANSMIT, "ai", param); +} + +/*legacy command*/ +static bool set_ir_command(char *command) +{ + DBusMessage *msg; + int val; + char *param[1]; + bool ret = FALSE; + + param[0] = command; + msg = dbus_method_sync_with_reply(DEVICED_BUS_NAME, + DEVICED_PATH_LED, + DEVICED_INTERFACE_LED, + METHOD_IR_SETIRCOMMAND, "s", param); + if (!msg) { + _E("fail : no reply"); + return ret; + } + + if (dbus_message_get_args(msg, NULL, DBUS_TYPE_INT32, &val, DBUS_TYPE_INVALID) == 0) + _E("fail : no message"); + else { + if ((val == -ENOTSUP) || (val == -ENOSYS)) { + _I("Not supported feature! : %d", val); + ret = TRUE; + } else if (val < 0) { + _E("fail : returned fail (%d)", val); + } else { + _I("success : %d", val); + ret = TRUE; + } + } + + dbus_message_unref(msg); + return ret; +} + +void ir_test_all(int *success, int *fail) +{ + int s = 0; + int f = 0; + + int pattern[5] = {100, 200, 300, 400, 500}; + + (get_ir_isavailable()) ? s++ : f++; + (set_ir_transmit(38000, pattern, 5)) ? s++ : f++; + (set_ir_command("N/A")) ? s++ : f++; + + + if (NULL != success) *success = s; + if (NULL != fail) *fail = f; +} + +static void ir_init(void *data) +{ + int success = 0; + int fail = 0; + + _I("start test"); + + ir_test_all(&success, &fail); + + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); +} + +static void ir_exit(void *data) +{ + _I("end test"); +} + +static int ir_unit(int argc, char **argv) +{ + if (argc < 4) { + int success = 0; + int fail = 0; + + _I("start test"); + ir_test_all(&success, &fail); + _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail); + } else if (0 == strcasecmp(argv[3], METHOD_IR_ISAVAILABLE)) { + get_ir_isavailable(); + //} else if (0 == strcasecmp(argv[3], METHOD_IR_TRANSMIT)) { + // set_ir_transmit(); + } else if (0 == strcasecmp(argv[3], METHOD_IR_SETIRCOMMAND)) { + set_ir_command(argv[4]); + } else { + _E("Unknown test case!!!"); + } + + return 0; +} + +static const struct test_ops ir_test_ops = { + .priority = TEST_PRIORITY_NORMAL, + .name = "ir", + .init = ir_init, + .exit = ir_exit, + .unit = ir_unit, +}; + +TEST_OPS_REGISTER(&ir_test_ops) diff --git a/src/auto-test/led.c b/src/auto-test/led.c index 3353d25..ab9bc4a 100755 --- a/src/auto-test/led.c +++ b/src/auto-test/led.c @@ -20,7 +20,6 @@ #include "test.h" #include -#define METHOD_LED_SETIRCOMMAND "SetIrCommand" #define METHOD_LED_PLAYCUSTOM "playcustom" #define METHOD_LED_STOPCUSTOM "stopcustom" //#define METHOD_LED_GETBRIGHTNESS_FORCAMERA "GetBrightnessForCamera" @@ -141,15 +140,6 @@ static bool set_led_stopcustom() return set_led_method(METHOD_LED_STOPCUSTOM, NULL, NULL); } -static bool set_led_ircommand(char *command) -{ - char *param[1]; - - param[0] = command; - - return set_led_method(METHOD_LED_SETIRCOMMAND, "s", param); -} - void led_test_all(int *success, int *fail) { int s = 0; @@ -161,7 +151,6 @@ void led_test_all(int *success, int *fail) (get_led_brightness()) ? s++ : f++; (set_led_playcustom(1, 0, RED, DEFAULT_FLAG)) ? s++ : f++; (set_led_stopcustom()) ? s++ : f++; - (set_led_ircommand("N/A")) ? s++ : f++; if (NULL != success) *success = s; if (NULL != fail) *fail = f; @@ -202,8 +191,6 @@ static int led_unit(int argc, char **argv) set_led_playcustom(atoi(argv[4]), atoi(argv[5]), strtoul(argv[6], NULL, 16), DEFAULT_FLAG); } else if (0 == strcasecmp(argv[3], METHOD_LED_STOPCUSTOM)) { set_led_stopcustom(); - } else if (0 == strcasecmp(argv[3], METHOD_LED_SETIRCOMMAND)) { - set_led_ircommand(argv[3]); } else { _E("Unknown test case!!!"); } -- 2.7.4