src/power/android/SDL_syspower.c
changeset 6450 cf62de5b978f
child 6887 78ad5efd6786
equal deleted inserted replaced
6449:fa00544b1374 6450:cf62de5b978f
       
     1 #include "SDL_config.h"
       
     2 
       
     3 #ifndef SDL_POWER_DISABLED
       
     4 #if SDL_POWER_ANDROID
       
     5 
       
     6 #include "SDL_power.h"
       
     7 
       
     8 #include "../../core/android/SDL_android.h"
       
     9 
       
    10 SDL_bool
       
    11 SDL_GetPowerInfo_Android(SDL_PowerState * state, int *seconds, int *percent)
       
    12 {
       
    13     int battery;
       
    14     int plugged;
       
    15     int charged;
       
    16 
       
    17     if (Android_JNI_GetPowerInfo(&plugged, &charged, &battery, seconds, percent) != -1) {
       
    18         if (plugged) {
       
    19             if (charged) {
       
    20                 *state = SDL_POWERSTATE_CHARGED;
       
    21             } else if (battery) {
       
    22                 *state = SDL_POWERSTATE_CHARGING;
       
    23             } else {
       
    24                 *state = SDL_POWERSTATE_NO_BATTERY;
       
    25                 *seconds = -1;
       
    26                 *percent = -1;
       
    27             }
       
    28         } else {
       
    29             *state = SDL_POWERSTATE_ON_BATTERY;
       
    30         }
       
    31     } else {
       
    32         *state = SDL_POWERSTATE_UNKNOWN;
       
    33         *seconds = -1;
       
    34         *percent = -1;
       
    35     }
       
    36 
       
    37     return SDL_TRUE;
       
    38 }
       
    39 
       
    40 #endif /* SDL_POWER_ANDROID */
       
    41 #endif /* SDL_POWER_DISABLED */