1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2010 by Thomas Martitz
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
28 extern jclass RockboxService_class
;
29 extern jobject RockboxService_instance
;
31 static jfieldID _battery_level
;
33 void powermgmt_init_target(void)
35 JNIEnv
*env_ptr
= getJavaEnvironment();
37 jmethodID initBatteryMonitor
= (*env_ptr
)->GetMethodID(env_ptr
,
41 /* start the monitor */
42 (*env_ptr
)->CallVoidMethod(env_ptr
,
43 RockboxService_instance
,
46 /* cache the battery level field id */
47 _battery_level
= (*env_ptr
)->GetFieldID(env_ptr
,
53 int battery_level(void)
55 JNIEnv
*env_ptr
= getJavaEnvironment();
57 return (*env_ptr
)->GetIntField(env_ptr
, RockboxService_instance
, _battery_level
);
60 int battery_time(void)
61 { /* cannot calculate yet */
65 /* should always be safe on android targets, the host shuts us down before */
66 bool battery_level_safe(void)
72 unsigned battery_voltage(void)