Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d848876f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Create wrapper function for set_wakeup_callback"

parents 8b18000b 2d441905
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -28,8 +28,7 @@ static struct autosuspend_ops *autosuspend_ops;
static bool autosuspend_enabled;
static bool autosuspend_inited;

static int autosuspend_init(void)
{
static int autosuspend_init(void) {
    if (autosuspend_inited) {
        return 0;
    }
@@ -51,8 +50,7 @@ out:
    return 0;
}

int autosuspend_enable(void)
{
int autosuspend_enable(void) {
    int ret;

    ret = autosuspend_init();
@@ -75,8 +73,7 @@ int autosuspend_enable(void)
    return 0;
}

int autosuspend_disable(void)
{
int autosuspend_disable(void) {
    int ret;

    ret = autosuspend_init();
@@ -98,3 +95,16 @@ int autosuspend_disable(void)
    autosuspend_enabled = false;
    return 0;
}

void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
    int ret;

    ret = autosuspend_init();
    if (ret) {
        return;
    }

    ALOGV("set_wakeup_callback");

    autosuspend_ops->set_wakeup_callback(func);
}
+1 −2
Original line number Diff line number Diff line
@@ -20,10 +20,9 @@
struct autosuspend_ops {
    int (*enable)(void);
    int (*disable)(void);
    void (*set_wakeup_callback)(void (*func)(bool success));
};

struct autosuspend_ops *autosuspend_autosleep_init(void);
struct autosuspend_ops *autosuspend_earlysuspend_init(void);
struct autosuspend_ops *autosuspend_wakeup_count_init(void);

#endif
+9 −13
Original line number Diff line number Diff line
@@ -55,8 +55,7 @@ static void update_sleep_time(bool success) {
    sleep_time = MIN(sleep_time * 2, 60000000);
}

static void *suspend_thread_func(void *arg __attribute__((unused)))
{
static void* suspend_thread_func(void* arg __attribute__((unused))) {
    char buf[80];
    char wakeup_count[20];
    int wakeup_count_len;
@@ -117,8 +116,7 @@ static void *suspend_thread_func(void *arg __attribute__((unused)))
    return NULL;
}

static int autosuspend_wakeup_count_enable(void)
{
static int autosuspend_wakeup_count_enable(void) {
    char buf[80];
    int ret;

@@ -136,8 +134,7 @@ static int autosuspend_wakeup_count_enable(void)
    return ret;
}

static int autosuspend_wakeup_count_disable(void)
{
static int autosuspend_wakeup_count_disable(void) {
    char buf[80];
    int ret;

@@ -155,8 +152,7 @@ static int autosuspend_wakeup_count_disable(void)
    return ret;
}

void set_wakeup_callback(void (*func)(bool success))
{
static void autosuspend_set_wakeup_callback(void (*func)(bool success)) {
    if (wakeup_func != NULL) {
        ALOGE("Duplicate wakeup callback applied, keeping original");
        return;
@@ -167,10 +163,10 @@ void set_wakeup_callback(void (*func)(bool success))
struct autosuspend_ops autosuspend_wakeup_count_ops = {
    .enable = autosuspend_wakeup_count_enable,
    .disable = autosuspend_wakeup_count_disable,
    .set_wakeup_callback = autosuspend_set_wakeup_callback,
};

struct autosuspend_ops *autosuspend_wakeup_count_init(void)
{
struct autosuspend_ops* autosuspend_wakeup_count_init(void) {
    int ret;
    char buf[80];

+1 −1
Original line number Diff line number Diff line
@@ -51,7 +51,7 @@ int autosuspend_disable(void);
 * success is true if the suspend was sucessful and false if the suspend
 * aborted due to some reason.
 */
void set_wakeup_callback(void (*func)(bool success));
void autosuspend_set_wakeup_callback(void (*func)(bool success));

__END_DECLS