31 #include <SDL2/SDL_system.h>
36 namespace battery_info {
42 #elif defined(__APPLE__)
44 #elif defined(HAVE_LIBDBUS)
46 #elif defined(__ANDROID__)
57 #elif defined(__APPLE__)
59 #elif defined(HAVE_LIBDBUS)
61 #elif defined(__ANDROID__)
63 JNIEnv* env =
reinterpret_cast<JNIEnv*
>(SDL_AndroidGetJNIEnv());
64 jobject wesnoth_instance =
reinterpret_cast<jobject
>(SDL_AndroidGetActivity());
65 jclass wesnoth_activity(env->GetObjectClass(wesnoth_instance));
66 jmethodID percentage = env->GetMethodID(wesnoth_activity,
"getBatteryPercentage",
"()D");
67 return env->CallDoubleMethod(wesnoth_instance, percentage);
static bool does_device_have_battery()
static double get_battery_percentage()
double get_battery_percentage()
bool does_device_have_battery()
double get_battery_percentage()
bool does_device_have_battery()
bool does_device_have_battery()
double get_battery_percentage()