Exemplo n.º 1
0
SDL_bool
SDL_GetPowerInfo_Android(SDL_PowerState * state, int *seconds, int *percent)
{
    int battery;
    int plugged;
    int charged;

    if (Android_JNI_GetPowerInfo(&plugged, &charged, &battery, seconds, percent) != -1) {
        if (plugged) {
            if (charged) {
                *state = SDL_POWERSTATE_CHARGED;
            } else if (battery) {
                *state = SDL_POWERSTATE_CHARGING;
            } else {
                *state = SDL_POWERSTATE_NO_BATTERY;
                *seconds = -1;
                *percent = -1;
            }
        } else {
            *state = SDL_POWERSTATE_ON_BATTERY;
        }
    } else {
        *state = SDL_POWERSTATE_UNKNOWN;
        *seconds = -1;
        *percent = -1;
    }

    return SDL_TRUE;
}
Exemplo n.º 2
0
bool power_android::GetPowerInfo_Android() {
	int battery;
	int plugged;
	int charged;

	if (Android_JNI_GetPowerInfo(&plugged, &charged, &battery, &this->nsecs_left, &this->percent_left) != -1) {
		if (plugged) {
			if (charged) {
				this->power_state = OS::POWERSTATE_CHARGED;
			} else if (battery) {
				this->power_state = OS::POWERSTATE_CHARGING;
			} else {
				this->power_state = OS::POWERSTATE_NO_BATTERY;
				this->nsecs_left = -1;
				this->percent_left = -1;
			}
		} else {
			this->power_state = OS::POWERSTATE_ON_BATTERY;
		}
	} else {
		this->power_state = OS::POWERSTATE_UNKNOWN;
		this->nsecs_left = -1;
		this->percent_left = -1;
	}

	return true;
}