Remove unused function low-power 22/248922/4 accepted/tizen/unified/20201207.123250 submit/tizen/20201204.013436
authorlokilee73 <changjoo.lee@samsung.com>
Thu, 3 Dec 2020 08:00:46 +0000 (17:00 +0900)
committerlokilee73 <changjoo.lee@samsung.com>
Thu, 3 Dec 2020 08:32:01 +0000 (17:32 +0900)
low-power.c is not used and duplicated with powersaver.c

Change-Id: I8e93891c41d83710d26e6d4ecbc2c9a5a77bc7bd
Signed-off-by: lokilee73 <changjoo.lee@samsung.com>
conf/org.tizen.system.deviced.conf
src/auto-test/power.c
src/power/low-power.c [deleted file]

index 4d99362..bafc8fa 100644 (file)
@@ -60,8 +60,6 @@
         <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.Core"/>
         <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.ExtCon"/>
 
-        <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.LowPower"/>
-
         <allow send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti"/>
         <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="getcontrol"/>
         <deny send_destination="org.tizen.system.deviced" send_interface="org.tizen.system.deviced.SysNoti" send_member="control"/>
index 2a88a98..29b6a3c 100644 (file)
 #define METHOD_POWEROFF             "PowerOff"
 #define METHOD_POWEROFF_WITH_OPTION "PowerOffWithOption"
 
-#define METHOD_LOWPOWER_START       "Start"
-#define METHOD_LOWPOWER_STOP        "Stop"
-#define METHOD_LOWPOWER_GETSTATE    "GetState"
-
 static bool set_reboot_method(const char *method, GVariant *param)
 {
        GVariant *msg;
@@ -68,77 +64,6 @@ static bool set_reboot_with_option(char *type, char *option)
        return set_reboot_method(METHOD_POWEROFF_WITH_OPTION, g_variant_new("(ss)", type, option));
 }
 
-static bool request_lowpower_method(const char *method, GVariant *param)
-{
-       GVariant *msg;
-       int val;
-       bool ret = FALSE;
-       int retry = 0;
-
-       while (retry++ < 3) {
-               msg = dbus_handle_method_sync_with_reply_var(DEVICED_BUS_NAME,
-                                                       DEVICED_PATH_LOWPOWER,
-                                                       DEVICED_INTERFACE_LOWPOWER,
-                                                       method,
-                                                       param);
-               if (!msg) {
-                       _E("fail (%s): no reply", method);
-                       return ret;
-               }
-
-               if (!g_variant_get_safe(msg, "(i)", &val))
-                       _E("fail (%s): no message", method);
-               else {
-                       if (val == -EAGAIN) {
-                               g_variant_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;
-                       }
-               }
-               g_variant_unref(msg);
-               break;
-       }
-
-       return ret;
-}
-
-static bool set_lowpower_start()
-{
-       return request_lowpower_method(METHOD_LOWPOWER_START, NULL);
-}
-
-static bool set_lowpower_stop()
-{
-       return request_lowpower_method(METHOD_LOWPOWER_STOP, NULL);
-}
-
-static bool set_lowpower_getstate()
-{
-       return request_lowpower_method(METHOD_LOWPOWER_GETSTATE, 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;
@@ -146,8 +71,6 @@ static void power_init(void *data)
 
        _I("start test");
 
-       lowpower_test_all(&success, &fail);
-
        _I("Total: %d, Success: %d, Fail: %d", success+fail, success, fail);
 }
 
@@ -163,22 +86,13 @@ static int power_unit(int argc, char **argv)
                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_POWEROFF))
                set_reboot(argv[4]);
        else if (0 == strcasecmp(argv[3], METHOD_POWEROFF_WITH_OPTION))
                set_reboot_with_option(argv[4], argv[5]);
-       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
+       else
                _E("Unknown test case!!!");
 
        return 0;
diff --git a/src/power/low-power.c b/src/power/low-power.c
deleted file mode 100644 (file)
index 9e77a79..0000000
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * deviced
- *
- * 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 <unistd.h>
-#include <time.h>
-#include <limits.h>
-#include <vconf.h>
-#include <glib.h>
-#include <libsyscommon/dbus-system.h>
-
-#include "core/log.h"
-#include "core/device-notifier.h"
-#include "core/device-idler.h"
-#include "core/common.h"
-#include "core/devices.h"
-
-#ifndef VCONFKEY_SYSMAN_LOW_POWER_MODE
-#define VCONFKEY_SYSMAN_LOW_POWER_MODE "db/sysman/low_power_mode"
-#define VCONFKEY_SYSMAN_LOW_POWER_MODE_OFF 0
-#define VCONFKEY_SYSMAN_LOW_POWER_MODE_ON  1
-#endif
-
-static bool low_power_enabled;
-
-static int low_power_start(void *data)
-{
-       int ret;
-
-       if (low_power_enabled)
-               return 0;
-
-       ret = vconf_set_int(VCONFKEY_SYSMAN_LOW_POWER_MODE,
-                       VCONFKEY_SYSMAN_LOW_POWER_MODE_ON);
-       if (ret < 0) {
-               _E("Failed to set vconf value for low power mode: %d", vconf_get_ext_errno());
-               return -ENOMEM;
-       }
-
-       low_power_enabled = true;
-       _I("Low Power Mode Start.");
-
-       return 0;
-}
-
-static int low_power_stop(void *data)
-{
-       int ret;
-
-       if (!low_power_enabled)
-               return 0;
-
-       ret = vconf_set_int(VCONFKEY_SYSMAN_LOW_POWER_MODE,
-                       VCONFKEY_SYSMAN_LOW_POWER_MODE_OFF);
-       if (ret < 0) {
-               _E("Failed to set vconf value for low power mode: %d", vconf_get_ext_errno());
-               return -ENOMEM;
-       }
-
-       low_power_enabled = false;
-       _I("Low Power Mode Stop.");
-
-       return 0;
-}
-
-static int booting_done(void *data)
-{
-       static int done = 0;
-       int mode, ret;
-
-       if (data == NULL)
-               goto out;
-       if (done)
-               goto out;
-
-       done = *(int*)data;
-
-       ret = vconf_get_int(VCONFKEY_SYSMAN_LOW_POWER_MODE, &mode);
-       if (ret == 0 && mode == VCONFKEY_SYSMAN_LOW_POWER_MODE_ON) {
-               _I("Low Power Mode Start.");
-               low_power_enabled = true;
-       } else if (ret < 0)
-               _E("Failed to get vconf value for low power mode: %d", vconf_get_ext_errno());
-
-out:
-       return done;
-}
-
-static GVariant *dbus_low_power_start(GDBusConnection *conn,
-       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
-       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       int ret;
-       pid_t pid;
-
-       if (!booting_done(NULL)) {
-               _I("Booting is not done yet.");
-               ret = -EAGAIN;
-               goto out;
-       }
-
-       pid = dbus_connection_get_sender_pid(conn, sender);
-       if (pid == -1 || kill(pid, 0) == -1) {
-               _E("Sender(%d) does not exist.", pid);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       _I("Low Power Mode started by PID(%d).", pid);
-       ret = low_power_start(NULL);
-       if (ret < 0)
-               _E("Failed to start Low Power Mode(%d).", ret);
-
-out:
-       return g_variant_new("(i)", ret);
-}
-
-static GVariant *dbus_low_power_stop(GDBusConnection *conn,
-       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
-       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       int ret;
-       pid_t pid;
-
-       if (!booting_done(NULL)) {
-               _I("Booting is not done yet.");
-               ret = -EAGAIN;
-               goto out;
-       }
-
-       pid = dbus_connection_get_sender_pid(conn, sender);
-       if (pid == -1 || kill(pid, 0) == -1) {
-               _E("Sender(%d) does not exist.", pid);
-               ret = -EINVAL;
-               goto out;
-       }
-
-       _I("Low Power Mode stopped by PID(%d).", pid);
-       ret = low_power_stop(NULL);
-       if (ret < 0)
-               _E("Failed to stop Low Power Mode(%d).", ret);
-
-out:
-       return g_variant_new("(i)", ret);
-}
-
-static GVariant *dbus_low_power_get_state(GDBusConnection *conn,
-       const gchar *sender, const gchar *path, const gchar *iface, const gchar *name,
-       GVariant *param, GDBusMethodInvocation *invocation, gpointer user_data)
-{
-       return g_variant_new("(i)", (low_power_enabled ? 1 : 0));
-}
-
-static const dbus_method_s dbus_methods[] = {
-       { "Start",      NULL, "i", dbus_low_power_start      },
-       { "Stop",       NULL, "i", dbus_low_power_stop       },
-       { "GetState",   NULL, "i", dbus_low_power_get_state  },
-       /* Add methods here */
-};
-
-static const dbus_interface_u dbus_interface = {
-       .oh = NULL,
-       .name = DEVICED_INTERFACE_LOWPOWER,
-       .methods = dbus_methods,
-       .nr_methods = ARRAY_SIZE(dbus_methods),
-};
-
-static void low_power_init(void *data)
-{
-       int ret;
-
-       /* init dbus interface */
-       ret = dbus_handle_add_dbus_object(NULL, DEVICED_PATH_LOWPOWER, &dbus_interface);
-       if (ret < 0)
-               _E("Failed to init dbus method(%d).", ret);
-
-       register_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-}
-
-static void low_power_exit(void *data)
-{
-       int ret;
-
-       ret = low_power_stop(NULL);
-       if (ret < 0)
-               _E("Failed to stop Low Power Mode(%d).", ret);
-
-       unregister_notifier(DEVICE_NOTIFIER_BOOTING_DONE, booting_done);
-}
-
-static const struct device_ops low_power_device_ops = {
-       .name     = "low-power",
-       .init     = low_power_init,
-       .exit     = low_power_exit,
-};
-
-DEVICE_OPS_REGISTER(&low_power_device_ops)