#include "display-info.h"
#define CHARGER_LCD_NODE "/sys/class/power_supply/battery/lcd"
+#define SIGNAL_HOMESCREEN "HomeScreen"
+#define CLOCK_CHANGED "clockchanged"
+#define CLOCK_END "clockend"
enum charging_lcd_state {
CHARGING_LCD_OFF = 0,
};
static guint autobrt_timer;
+static bool lcdon_from_aod;
+static int autobrtlevel;
static gboolean display_autobrt_changed(gpointer data)
{
* effect seems sluggish because of heavy load of jobs for turning on
* display. So delay this brightness change a bit to avoid this
* heavy loaded time and therefore make it change smoothly. */
- autobrt_timer = g_timeout_add(200, display_autobrt_changed, (gpointer)level);
+ if (lcdon_from_aod) {
+ autobrtlevel = level;
+ autobrt_timer = g_timeout_add(200, display_autobrt_changed, (gpointer)level);
+ } else {
+ display_autobrt_changed((gpointer)level);
+ }
} else {
ret = -ENOTSUP;
}
return g_variant_new("(i)", ret);
}
+static void aod_change_signal(GDBusConnection *conn,
+ const gchar *sender,
+ const gchar *path,
+ const gchar *iface,
+ const gchar *name,
+ GVariant *param,
+ gpointer data)
+
+{
+ char *screen;
+
+ g_variant_get(param, "(s)", &screen);
+
+ /* clock-viewer send "clockchanged" as signal parameter when AOD->LCDON.
+ * On catching this signal, do change brightness immediately. */
+ if (!strncmp(screen, CLOCK_CHANGED, strlen(CLOCK_CHANGED))) {
+ lcdon_from_aod = false;
+ if (autobrt_timer) {
+ g_source_remove(autobrt_timer);
+ display_autobrt_changed((gpointer)autobrtlevel);
+ }
+ } else if (!strncmp(screen, CLOCK_END, strlen(CLOCK_END))) {
+ lcdon_from_aod = true;
+ }
+
+ g_free(screen);
+}
+
static const dbus_method_s dbus_methods[] = {
{ "AutoBrightnessChanged", "i", "i", dbus_autobrightnesschanged },
};
prepare_level_handler();
register_notifier(DEVICE_NOTIFIER_LCD, display_state_changed);
+ lcdon_from_aod = false;
+ ret = subscribe_dbus_signal(NULL,
+ DEVICED_OBJECT_PATH,
+ DEVICED_INTERFACE_NAME,
+ SIGNAL_HOMESCREEN,
+ aod_change_signal,
+ NULL, NULL);
+ if (ret <= 0)
+ _E("Failed to register signal handler: %d", ret);
+
ret = sys_set_int(CHARGER_LCD_NODE, CHARGING_LCD_ON);
if (ret < 0)
_E("Can't write %s node.", CHARGER_LCD_NODE);