src/power/android/SDL_syspower.c
author Sam Lantinga <slouken@libsdl.org>
Sun, 23 Sep 2012 01:54:30 -0700
changeset 6450 cf62de5b978f
child 6887 78ad5efd6786
permissions -rw-r--r--
Added missing Android source that was supposed to go with changeset 64a6297a8b93 Thank you buildbot!
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
6450
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     1
#include "SDL_config.h"
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     2
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     3
#ifndef SDL_POWER_DISABLED
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     4
#if SDL_POWER_ANDROID
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     5
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     6
#include "SDL_power.h"
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     7
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     8
#include "../../core/android/SDL_android.h"
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
     9
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    10
SDL_bool
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    11
SDL_GetPowerInfo_Android(SDL_PowerState * state, int *seconds, int *percent)
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    12
{
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    13
    int battery;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    14
    int plugged;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    15
    int charged;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    16
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    17
    if (Android_JNI_GetPowerInfo(&plugged, &charged, &battery, seconds, percent) != -1) {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    18
        if (plugged) {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    19
            if (charged) {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    20
                *state = SDL_POWERSTATE_CHARGED;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    21
            } else if (battery) {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    22
                *state = SDL_POWERSTATE_CHARGING;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    23
            } else {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    24
                *state = SDL_POWERSTATE_NO_BATTERY;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    25
                *seconds = -1;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    26
                *percent = -1;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    27
            }
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    28
        } else {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    29
            *state = SDL_POWERSTATE_ON_BATTERY;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    30
        }
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    31
    } else {
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    32
        *state = SDL_POWERSTATE_UNKNOWN;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    33
        *seconds = -1;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    34
        *percent = -1;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    35
    }
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    36
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    37
    return SDL_TRUE;
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    38
}
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    39
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    40
#endif /* SDL_POWER_ANDROID */
cf62de5b978f Added missing Android source that was supposed to go with changeset 64a6297a8b93
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
    41
#endif /* SDL_POWER_DISABLED */